Skip to content

Commit

Permalink
Don't create media state for text until ready to stream.
Browse files Browse the repository at this point in the history
We start streaming text once subtitles have been enabled.
With external text, we used to create a media state for it
as soon as text was added even if captions were disabled
and we did not actually stream, although no text was
being parsed and shown.
This lead to the following problem:
If external text was added with subtitles disabled, we
created the media state with no actual cues in it.
Once the subtitles were enabled, we saw that a media
state existed for text and assumed it had content.
So, we started streaming, but nothing was shown.
This change makes us only create the media state if
subtitles are enabled and defer creation otherwise.

Closes #1938.

Change-Id: Iee39c30fbd6b7f0abe7772dfb75cba561fcc9998
  • Loading branch information
ismena committed Jun 25, 2019
1 parent aa25956 commit fc3f750
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/media/streaming_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,16 @@ shaka.media.StreamingEngine = class {
await this.setupStreams_(streamSet);
this.destroyer_.ensureNotDestroyed();

const showText = this.playerInterface_
.mediaSourceEngine
.getTextDisplayer()
.isTextVisible();

const streamText = showText || this.config_.alwaysStreamText;

if ((this.textStreamSequenceId_ == currentSequenceId) &&
!this.mediaStates_.has(ContentType.TEXT) &&
!this.unloadingTextStream_) {
!this.unloadingTextStream_ && streamText) {
const presentationTime = this.playerInterface_.getPresentationTime();
const needPeriodIndex = this.findPeriodForTime_(presentationTime);

Expand Down

0 comments on commit fc3f750

Please sign in to comment.