Enve Enve - 1 year ago 60
jQuery Question

showTextTrack in Video.js 5

I am trying to change the active caption track from JavaScript in Video.js v5.10.4. I saw a few posts about this and they all suggested to use

, but when I execute the command it says that
showTextTrack is not a function
. I currently have the following code

var video = videojs('video');
var first_track_id = video.textTracks().tracks_[0].id; // this returns vjs_track_399
video.showTextTrack(first_track_id, "captions"); // this returns the error above

Is there any other way to accomplish what I am trying to do, or what am I doing wrong?

Answer Source

showTextTracks() was for video.js 4. Now you just set the mode of the track to showing:

video.textTracks()[0].mode = 'showing';