Skip to content

Commit

Permalink
Fix bug with text displayer switching.
Browse files Browse the repository at this point in the history
The new support for replacing the text displayer mid-playback had an
uncaught problem. Specifically, loading a new asset while an old asset
was playing caused an error.
This was because it was trying to reload the existing text stream when
there was no text stream.

This changes the reloadTextStream method on streaming engine to do
nothing if there is no text stream, fixing that problem.

Change-Id: I53f25fb14a54670697ad014bc6e6f72f6cc28577
  • Loading branch information
theodab committed May 15, 2019
1 parent a9b24b8 commit af259c4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/media/streaming_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -696,8 +696,10 @@ shaka.media.StreamingEngine.prototype.switchTextStream = function(textStream) {
shaka.media.StreamingEngine.prototype.reloadTextStream = function() {
const ContentType = shaka.util.ManifestParserUtils.ContentType;
const mediaState = this.mediaStates_.get(ContentType.TEXT);
this.switchInternal_(mediaState.stream, /* clearBuffer= */ true,
/* safeMargin= */ 0, /* force= */ true);
if (mediaState) { // Don't reload if there's no text to begin with.
this.switchInternal_(mediaState.stream, /* clearBuffer= */ true,
/* safeMargin= */ 0, /* force= */ true);
}
};


Expand Down

0 comments on commit af259c4

Please sign in to comment.