Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API enhancements for audio and subtitle selection #5978

Merged
merged 1 commit into from
Nov 27, 2023

Conversation

robwalch
Copy link
Collaborator

@robwalch robwalch commented Nov 16, 2023

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:

"audioPreference": {
  "audioCodec": "ec-3",
  "characteristics": "public.accessibility.describes-video"
},
"subtitlePreference": {
  "name": "English"
 }

Options can be changed at runtime

// switch to DVS audio
hls.setAudioOption({ characteristics: 'public.accessibility.describes-video' });

// switch to English SDH audio
hls.setSubtitleOption({
  lang: 'en-US',
  characteristics: 'public.accessibility.transcribes-spoken-dialog,public.accessibility.describes-music-and-sound'
});

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

  • changes have been done against master branch, and PR does not conflict
  • new unit / functional tests have been added (whenever applicable)
  • API or design changes are documented in API.md

@robwalch robwalch added this to the 1.5.0 milestone Nov 16, 2023
@robwalch robwalch self-assigned this Nov 17, 2023
@robwalch
Copy link
Collaborator Author

robwalch commented Nov 17, 2023

cc @agajassi @luwes

@robwalch robwalch force-pushed the feature/api-audio-subtitle-selection branch from a22b718 to a388134 Compare November 26, 2023 18:31
@robwalch robwalch force-pushed the feature/api-audio-subtitle-selection branch from a388134 to d4d585b Compare November 26, 2023 18:35
@robwalch robwalch merged commit 202ba5f into master Nov 27, 2023
15 of 16 checks passed
@robwalch robwalch deleted the feature/api-audio-subtitle-selection branch November 27, 2023 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API enhancements for audio (and subtitle) track selection
1 participant