Skip to content

Commit

Permalink
fix: When disconnecting from chromecast, subtitles are turned off (#6103
Browse files Browse the repository at this point in the history
)

Fixes #4036
  • Loading branch information
avelad committed Jan 16, 2024
1 parent 68b2a54 commit d4cd66d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/cast/cast_proxy.js
Expand Up @@ -496,6 +496,16 @@ shaka.cast.CastProxy = class extends shaka.util.FakeEventTarget {
startTime = this.sender_.get('video', 'currentTime');
}

let activeTextTrack;
const textTracks = this.sender_.get('player', 'getTextTracks')();

if (textTracks && textTracks.length) {
activeTextTrack = textTracks.find((t) => t.active);
}

const isTextTrackVisible =
this.sender_.get('player', 'isTextTrackVisible')();

// Now load the manifest, if present.
if (assetUri) {
// Don't autoplay the content until we finish setting up initial state.
Expand Down Expand Up @@ -527,6 +537,14 @@ shaka.cast.CastProxy = class extends shaka.util.FakeEventTarget {
/** @type {Object} */(this.localPlayer_)[setter](value);
}

this.localPlayer_.setTextTrackVisibility(isTextTrackVisible);
if (activeTextTrack) {
this.localPlayer_.selectTextLanguage(
activeTextTrack.language,
activeTextTrack.roles,
activeTextTrack.forced);
}

// Restore the original autoplay setting.
this.localVideo_.autoplay = autoplay;
if (assetUri) {
Expand Down

0 comments on commit d4cd66d

Please sign in to comment.