Skip to content

Commit

Permalink
[MSS] fix issue when selecting new audio track and new text track sim…
Browse files Browse the repository at this point in the history
…ultaneously on live streams (#3749)
  • Loading branch information
bbert authored Sep 3, 2021
1 parent 356b6f6 commit 283df6b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/streaming/Stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function Stream(config) {
boxParser,
debug,
isEndedEventSignaled,
trackChangedEvent;
trackChangedEvents;

/**
* Setup the stream
Expand Down Expand Up @@ -555,6 +555,7 @@ function Stream(config) {
updateError = {};
isUpdating = false;
isEndedEventSignaled = false;
trackChangedEvents = [];
}

function reset(keepBuffers) {
Expand Down Expand Up @@ -671,7 +672,7 @@ function Stream(config) {
// Applies only for MSS streams
if (manifest.refreshManifestOnSwitchTrack) {
logger.debug('Stream - Refreshing manifest for switch track');
trackChangedEvent = e;
trackChangedEvents.push(e);
manifestUpdater.refreshManifest();
} else {
processor.selectMediaInfo(mediaInfo)
Expand Down Expand Up @@ -866,13 +867,13 @@ function Stream(config) {
.then(() => {
promises = [];

if (trackChangedEvent) {
while (trackChangedEvents.length > 0) {
let trackChangedEvent = trackChangedEvents.pop();
let mediaInfo = trackChangedEvent.newMediaInfo;
let processor = getProcessorForMediaInfo(trackChangedEvent.oldMediaInfo);
if (!processor) return;
promises.push(processor.prepareTrackSwitch());
processor.selectMediaInfo(mediaInfo);
trackChangedEvent = undefined;
}

return Promise.all(promises)
Expand Down

0 comments on commit 283df6b

Please sign in to comment.