AVMediaSelectionOption Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/AVFoundation.framework
Availability
Available in iOS 5.0 and later.
Companion guide
Declared in
AVMediaSelectionGroup.h

Overview

An AVMediaSelectionOption object represents a specific option for the presentation of media within a group of options.

Tasks

Managing Media Types

Managing Metadata

New Methods

Properties

availableMetadataFormats

The metadata formats that contains metadata associated with the option. (read-only)

@property(nonatomic, readonly) NSArray *availableMetadataFormats
Discussion

The array contains NSString objects, each representing a metadata format that contains metadata associated with the option (for example, ID3, iTunes metadata, and so on).

Availability
  • Available in iOS 5.0 and later.
Declared In
AVMediaSelectionGroup.h

commonMetadata

An array of metadata items for each common metadata key for which a value is available. (read-only)

@property(nonatomic, readonly) NSArray *commonMetadata
Discussion

You can filter the array of AVMetadataItem objects according to locale using metadataItemsFromArray:withLocale: or according to key using metadataItemsFromArray:withKey:keySpace:.

The following example illustrates how to obtain the name (or title) of a media selection option in the current locale.

NSArray *titles = [AVMetadataItem metadataItemsFromArray:[mediaSelectionOption commonMetadata]
                                  withKey:AVMetadataCommonKeyTitle keySpace:AVMetadataKeySpaceCommon];
        if ([titles count] > 0) {
                // Try to get a title that matches one of the user's preferred languages.
                NSArray *preferredLanguages = [NSLocale preferredLanguages];
 
                for (NSString *thisLanguage in preferredLanguages) {
                        NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:thisLanguage];
                        NSArray *titlesForLocale = [AVMetadataItem metadataItemsFromArray:titles withLocale:locale];
                        [locale release];
                        if ([titlesForLocale count] > 0) {
                                title = [[titlesForLocale objectAtIndex:0] stringValue];
                                break;
                        }
 
                }
 
                // No matches in any of the preferred languages. Just use the primary title metadata we find.
                if (title == nil) {
                        title = [[titles objectAtIndex:0] stringValue];
                }
        }
Availability
  • Available in iOS 5.0 and later.
Declared In
AVMediaSelectionGroup.h

locale

The locale for which the media option was authored. (read-only)

@property(nonatomic, readonly) NSLocale *locale
Availability
  • Available in iOS 5.0 and later.
Declared In
AVMediaSelectionGroup.h

mediaSubTypes

The media sub-types of the media data associated with the option. (read-only)

@property(nonatomic, readonly) NSArray *mediaSubTypes
Discussion

The value is an array of NSNumber objects carrying four character codes (of type FourCharCode) as defined in CoreAudioTypes.h for audio media and in CMFormatDescription.h for video media.

Also see CMFormatDescriptionGetMediaSubType for more information about media subtypes.

Availability
  • Available in iOS 5.0 and later.
Declared In
AVMediaSelectionGroup.h

mediaType

The media type of the media data. (read-only)

@property(nonatomic, readonly) NSString *mediaType
Discussion

The value of the property might be, for example, AVMediaTypeAudio or AVMediaTypeSubtitle.

Availability
  • Available in iOS 5.0 and later.
Declared In
AVMediaSelectionGroup.h

playable

Indicates whether the media selection option is playable. (read-only)

@property(nonatomic, readonly, getter=isPlayable) BOOL playable
Discussion

If the media data associated with the option cannot be decoded or otherwise rendered, the value of this property is NO.

Availability
  • Available in iOS 5.0 and later.
Declared In
AVMediaSelectionGroup.h

Instance Methods

associatedMediaSelectionOptionInMediaSelectionGroup:

Returns a media selection option associated with the receiver in a given group.

- (AVMediaSelectionOption *)associatedMediaSelectionOptionInMediaSelectionGroup:(AVMediaSelectionGroup *)mediaSelectionGroup
Parameters
mediaSelectionGroup

A media selection group in which an associated option is to be sought.

Return Value

A media selection option associated with the receiver in mediaSelectionGroup, or nil if none were found.

Discussion

Audible media selection options often have associated legible media selection options; in particular, audible options are typically associated with forced-only subtitle options with the same locale. See AVMediaCharacteristicContainsOnlyForcedSubtitles in AVMediaFormat.h for a discussion of forced-only subtitles.

Availability
  • Available in iOS 5.0 and later.
Declared In
AVMediaSelectionGroup.h

hasMediaCharacteristic:

Returns a Boolean that indicates whether the receiver includes media a given media characteristic.

- (BOOL)hasMediaCharacteristic:(NSString *)mediaCharacteristic
Parameters
mediaCharacteristic

The media characteristic of interest, for example, AVMediaCharacteristicVisual, AVMediaCharacteristicAudible, or AVMediaCharacteristicLegible.

Return Value

YES if the media selection option includes media with mediaCharacteristic, otherwise NO.

Availability
  • Available in iOS 5.0 and later.
Declared In
AVMediaSelectionGroup.h

metadataForFormat:

Returns an array of AVMetadataItem objects, one for each metadata item in the container of a given format.

- (NSArray *)metadataForFormat:(NSString *)format
Parameters
format

The metadata format for which items are requested.

Return Value

An array of AVMetadataItem objects, one for each metadata item in the container of format, or nil if there is no metadata of the specified format.

Availability
  • Available in iOS 5.0 and later.
Declared In
AVMediaSelectionGroup.h

propertyList

Returns a serializable property list that’s sufficient to identify the option within its group.

- (id)propertyList
Return Value

A serializable property list that you can use to obtain an instance of AVMediaSelectionOption representing the same option as the receiver using mediaSelectionOptionWithPropertyList:.

Discussion

You can serialize the returned property list using NSPropertyListSerialization.

Availability
  • Available in iOS 5.0 and later.
Declared In
AVMediaSelectionGroup.h

Did this document help you? Yes It's good, but... Not helpful...