-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Interacting with VideoJS cues (vtt captions) from javascript #1984
Comments
As @heff said in IRC and the SO, it's because the tracks haven't necessarily loaded. If you interact with the tracks after a |
Hi @gkatsev, A quick question, exists some way to get the name of vtt file? It's for sending the path to my chromecast application. Thanks! |
@chimilord At what point are you wanting to get the name of the vtt file?
// textTrack and remoteTextTrack seem to both be populated regardless of how the text track was added.
videojs('player_id').textTracks()[0].src
videojs('player_id').remoteTextTracks()[0].src
videojs('player_id').getTrackById('captions').src // only available to browsers with native text tracks—you do not need to rely on the load event
document.querySelector('#captions').addEventListener('load', function (event) {
// event.target.src === captions.vtt
// event.srcElement.src === captions.vtt
// event.target.track === TextTrack{}
}); |
As @chemoish said, if you're using native text tracks, you can grab it from the track element ( Hopefully, at some point we'll actually emulate the Track element (since we need it for the |
Interesting, I haven't ran that use case before. Reference: |
Cross posted from StackOverflow. Any help is greatly appreciated!
I'm attempting to interact with cues loaded from a
vtt
file viavideo.js
. I can do it easily and repeatable from the browser inspect console but never from thevideojs
load-success function. I have a suspicion that thetextTrack
is parsed (I can access id, kind, mode attributes) but not read (cues are null). I can't find anywhere in the documentation or source if there is a way to force the track to be read or if there is a callback or event I should be listening for.Basic video.js invocation. Working fine, showing captions and video:
js, attempting to access cues:
console.log:
interactive console:
Tested with latest grunt-built master branch (version
4.12.5
) in Google Chrome Version41.0.2272.104 (64-bit)
The text was updated successfully, but these errors were encountered: