Closed siuying closed 9 years ago
var params = {url: "the-url", subtitles: {"English": "subs-url"}},
player = new wjs("#player").addPlayer({ autoplay: true }),
firstTime = true;
player.onMediaChanged(function() { firstTime = true; });
player.onEnded(function() { firstTime = true; });
player.onStopped(function() { firstTime = true; });
player.onPlaying(function() {
if (firstTime) {
firstTime = false;
player.subTrack(1);
}
});
player.addPlaylist(params);
Thanks! that's what I needed.
make sure you use the latest example code i posted in the comment (i changed it a few times), also there might be better ways to do it, this is just the first way I thought of..
got it! 👍
Can I set subtitles programmatically? This is how I add subtitle:
However, this would only add the subtitles to video, not activate them. User would have to manually select the subs from menu.
Adding
subTrack()
do not seems help (it would work if the video is loaded and i run it in console)