Version: 2.67.0

Pass subtitle selection on to Chromecast

Problem

At the moment it is intended behavior that when you start casting the player to a chromecast device the subtitle selection settings isn't carried over. A new player is generated with the SourceConfiguration of the sender, but not any adjustments. A client might not believe in our philosophy and request it gets send as well

Solution

The code adds an event on textTracks 'change'. Whenever the subtitles change, this event is called and stores the current active texttrack in 'currentTextTrack' by iterating over the textTracks array and checking wether .mode is on 'showing'. Once a Chromecast session is created, the code will check if the ID of the textTracks in the new player corresponds with the ID of the stored currentTextTrack. If so, it will activate that textTrack.

Web SDK

var currentTextTrack;
player.textTracks.addEventListener("change", function() {
for (var t in player.textTracks) {
if (player.textTracks[t].mode === "showing") {
currentTextTrack = player.textTracks[t];
}
}
});
player.cast.chromecast.addEventListener("statechange", event => {
if (event.state === "connected") {
player.addEventListener("playing", function() {
for (var tt in player.textTracks) {
if (player.textTracks[tt].id === currentTextTrack.id) {
player.textTracks[tt].mode = "showing";
}
}
});
}
});

iOS SDK

WIP

Android SDK

WIP