preferredAudioLanguage
Sets the preferred audio language and associated track properties for the media player.
This function allows you to specify the desired audio language, optional roles (e.g., main audio, audio description for accessibility), and optional codec/MIME type that the media player should prioritize when multiple audio tracks are available for the currently playing media.
When specifying a language code, it should be a valid IETF BCP 47 language code. Note that language code tags can also be specified as ISO 639-2/3 (three-letter codes). BCP 47 is the IETF's Best Current Practices for language tags, defined in RFC 5646, and it incorporates ISO 639 codes as primary language subtags. The authoritative source for valid BCP 47 subtags, including those derived from ISO 639, is the IANA Language Subtag Registry. This registry ensures a single, unambiguous subtag for each language, resolving potential conflicts or ambiguities that might arise from different ISO 639 parts.
The AudioLanguageInfo data object encapsulates:
languageCode: A String representing the desired audio language (e.g., "en" for English, "es" for Spanish, "fr-CA" for Canadian French). Required.
roles: An optional list of AudioTrackRole values indicating accessibility or special track roles (e.g., AudioTrackRole.MAIN for primary audio, AudioTrackRole.DESCRIBES_VIDEO for audio descriptions). Pass
nullto ignore role preferences. These roles map to AndroidX Media3's role flags for track selection with accessibility support.mimeType: An optional MIME type (codec identifier) such as "audio/eac3-joc" (Dolby Atmos), "audio/eac3" (Dolby Digital Plus), or "audio/mp4a-latm" (AAC). Pass
nullto allow any codec.
Parameters
An AudioLanguageInfo object containing language code and optional role/codec preferences.