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

Fix captions disappear on unbuffered seeks when user activates, deactivates, and reactivates captions #2674

Merged
Merged
1 change: 1 addition & 0 deletions lib/media/streaming_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ shaka.media.StreamingEngine = class {
this.abortOperations_(state).catch(() => {});
this.mediaStates_.delete(ContentType.TEXT);
}
this.currentTextStream_ = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, wow, that certainly should have been there. :-)

This member is new in v3.0 if I recall correctly.

}

/**
Expand Down
14 changes: 14 additions & 0 deletions test/media/streaming_engine_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,20 @@ describe('StreamingEngine', () => {
}
});
});

it('sets the current text stream to null', async () => {
createStreamingEngine();

streamingEngine.switchVariant(variant);
streamingEngine.switchTextStream(textStream);
expect(streamingEngine.getCurrentTextStream()).not.toBe(null);

await streamingEngine.start();
playing = true;

streamingEngine.unloadTextStream();
expect(streamingEngine.getCurrentTextStream()).toBe(null);
});
});

it('initializes and plays live', async () => {
Expand Down
9 changes: 6 additions & 3 deletions ui/text_selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,13 @@ shaka.ui.TextSelection = class extends shaka.ui.SettingsMenu {
* @private
*/
async onTextTrackSelected_(track) {
// setTextTrackVisibility should be called after selectTextLanguage.
// selectTextLanguage sets a text stream, and setTextTrackVisiblity(true)
// will set a text stream if it isn't already set. Consequently, reversing
// the order of these calls makes two languages display simultaneously
// if captions are turned off -> on in a different language.
this.player.selectTextLanguage(track.language, track.roles[0]);
await this.player.setTextTrackVisibility(true);
if (this.player) { // May have become null while awaiting
this.player.selectTextLanguage(track.language, track.roles[0]);
}
}


Expand Down