API enhancements for audio and subtitle selection #5978
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR will...
Adds config options and API methods for selecting audio and subtitles based on the attributes of media options (language, characteristics, associated language, channels, codec, name, group).
Why is this Pull Request needed?
The primary goal of this feature is to simplify the initial selection of audio and subtitles on startup.
By default, the player will attempt to start playback using default audio (stereo) and default subtitle options. These options and methods allow for the selection of audio and subtitles on startup and during playback, both with and without specific knowledge of the renditions available in an HLS asset.
Since the change from one audio group to another can necessitate a level switch, this API performs these changes when needed. This API allows for switching between change sets, which is impossible using the audioTrack setters (since audioTracks only expose the options with the groups available to the current level).
Are there any points in the code the reviewer needs to double check?
Safari supports all audio codec families in the Advanced stream example (mp4a, ac-3, ec-3):
https://devstreaming-cdn.apple.com/videos/streaming/examples/adv_dv_atmos/main.m3u8
Branch test URL
The preferences can be tested on the demo page by adding them to the config:
Options can be changed at runtime
The preferences and setters support both track objects as input (
hls.audioTracks | subtitleTracks | allAudioTracks | allSubtitleTracks
) as well as an object with any number of supported fields. The player will look for an exact match in the active groups first. If none is found it will look across all groups for an exact match which will requires a level change to complete.Resolves issues:
Resolves #5532
Checklist