Skip to content

Commit

Permalink
select audio group on LEVEL_LOADING
Browse files Browse the repository at this point in the history
  • Loading branch information
mad-gooze committed Oct 6, 2019
1 parent 3c94a82 commit 34a16e2
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/controller/audio-track-controller.js
Expand Up @@ -31,6 +31,7 @@ class AudioTrackController extends TaskLoop {
Event.MANIFEST_PARSED,
Event.AUDIO_TRACK_LOADED,
Event.AUDIO_TRACK_SWITCHED,
Event.LEVEL_LOADING,
Event.LEVEL_LOADED,
Event.ERROR
);
Expand Down Expand Up @@ -91,8 +92,6 @@ class AudioTrackController extends TaskLoop {
onManifestParsed (data) {
const tracks = this.tracks = data.audioTracks || [];
this.hls.trigger(Event.AUDIO_TRACKS_UPDATED, { audioTracks: tracks });

this._selectAudioGroup(this.hls.nextLoadLevel);
}

/**
Expand Down Expand Up @@ -143,14 +142,23 @@ class AudioTrackController extends TaskLoop {
}

/**
* When a level gets loaded, if it has redundant audioGroupIds (in the same ordinality as it's redundant URLs)
* When a level starts loading, if it has redundant audioGroupIds (in the same ordinality as it's redundant URLs)
* we are setting our audio-group ID internally to the one set, if it is different from the group ID currently set.
*
* If group-ID got update, we re-select the appropriate audio-track with this group-ID matching the currently
* selected one (based on NAME property).
*
* @param {*} data
*/
onLevelLoading (data) {
this._selectAudioGroup(data.level);
}

/**
* Runs the same logic when level gets loaded
*
* @param {*} data
*/
onLevelLoaded (data) {
this._selectAudioGroup(data.level);
}
Expand Down

0 comments on commit 34a16e2

Please sign in to comment.