benjipott / video.js-chromecast

Use chromecast with videojs html5 player
Other
207 stars 86 forks source link

[Fix activeTrackIds] Set the selected subtitle active before casting #48

Closed payflix closed 6 years ago

payflix commented 6 years ago

Substitles are never casted even if selected in videojs Adding this piece of code automatically sets the active trackId before casting

Place this code between line 251 and 252 in chromecast.js

var activeTrack = 0
document.querySelectorAll('.vjs-menu-content > .vjs-captions-menu-item').forEach(function(el, i) {
     if (el.classList.contains('vjs-selected')) {
          activeTrack = (i + 1)
     }
})
loadRequest.activeTrackIds = [activeTrack];
benjipott commented 6 years ago

you can create a PullRequest, thk's