Instance Method

initWithPreferredLanguages:preferredMediaCharacteristics:

Creates an initialized media selection criteria instance with the specified settings.

Declaration

- (instancetype)initWithPreferredLanguages:(NSArray<NSString *> *)preferredLanguages preferredMediaCharacteristics:(NSArray<AVMediaCharacteristic> *)preferredMediaCharacteristics;

Parameters

preferredLanguages

An array of strings containing language identifiers, in the preferred order. Can be nil.

preferredMediaCharacteristics

An array of strings indicating additional media characteristics, the preferred order. Can be nil.

Supported media characteristics are defined in AVMediaSelectionOption Constants and Media Characteristics.

Return Value

An initialized AVPlayerMediaSelectionCriteria instance.

Discussion

When making selections, AVPlayer treats the preferredLanguages as the paramount criterion and the preference for preferredMediaCharacteristics as secondary.

The objects in the preferredLanguages array are indicated using BCP 47 language identifiers or ISO 639-2/T language codes.

If no option with any of the preferredLanguages is available, a selection is made according to the default enabling and disabling of media options as stored in the asset.

The preferredMediaCharacteristics are used when selecting media for the AVPlayer.

For example, desirable characteristics of legible media may include AVMediaCharacteristicTranscribesSpokenDialogForAccessibility and AVMediaCharacteristicDescribesMusicAndSoundForAccessibility.

Similarly, desirable characteristics of audible media may include AVMediaCharacteristicDescribesVideoForAccessibility.

If no option is found that possesses all of the desired characteristics, the option that best matches the desired characteristics will be selected.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software