-
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
Load text tracks on demand. #2192
Conversation
Not to dig into unrelated things, but does this line do something? video.js/src/js/tracks/text-track.js Line 63 in 69a4884
|
It does. It causes the |
if (mode !== 'disabled' && this['cues'].length === 0) { | ||
loadTrack(this.src_, this); | ||
} | ||
|
||
if (mode === 'showing') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should include hidden tracks too so cuechange events fire for those also. Would that mess anything up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should.
Looks good to me. What are the open questions around how we want to handle tracks? |
Specifically, this is a change in functionality. Previously, all tracks and their cues were available after load and now they won't be available until they're selected. Possibly, we want to be able to load all the tracks sequentially starting with the default tracks (and the selected tracks) rather than only loading tracks on-demand. |
Ok, so it ads an asynchronous step for each track as opposed to all up front. Do we know how the video element handles this by default? |
I think it does load them all up as soon as possible, though, haven't tried it yet. |
Actually, looks like chrome doesn't have any of the cues available until the track is shown and chrome only uses either the "best match", top/first, or the default track. So, actually, this won't be too dissimilar. |
Nice. That's good. In Chrome are the cues available synchronously after showing a track? |
Doesn't seem to be the case in chrome. Btw, here's a test page modified from #1913: http://output.jsbin.com/rubacujite/1/edit?html,output |
This means that chapters, metadata, and descriptions will get loaded by default on init instead of on demand.
Ugh, this has turned into a much worse thing to fix than I thought :) |
I'm going to put this one on ice for a bit. The main issue with the really large text tracks from #1913 is that vttjs takes too long to parse (mozilla/vtt.js#340). Hopefully, I'll have some time later to look into that but don't have it immediately. |
Going to close this PR. We can revisit it after the vttjs issue has been fixed. |
Reimplementation of videojs#2192 on current code. Seems to work but has not been carefully tested, especially on conditions such as slow networks and complex tracks. For videojs#5252 A `preloadTextTracks` tech option is added, set to true by default, to keep current behavior intact. Alternate behavior can be enabled by setting this to false. This delays loading of the VTT cue files until they are selected. For sites like Wikipedia that tend to have large numbers of crowdsourced subtitles and can show many files together on one page, this saves a lot of unnecessary network transfer and API hits. Does mean there may be dropped cues while switching to a track that requires on-demand loading. Example usage: videojs(element, { html5: { preloadTextTracks: false } };
Reimplementation of #2192 on current code. Seems to work but has not been carefully tested, especially on conditions such as slow networks and complex tracks. For #5252 A `preloadTextTracks` tech option is added, set to true by default, to keep current behavior intact. Alternate behavior can be enabled by setting this to false. This delays loading of the VTT cue files until they are selected. For sites like Wikipedia that tend to have large numbers of crowdsourced subtitles and can show many files together on one page, this saves a lot of unnecessary network transfer and API hits. Does mean there may be dropped cues while switching to a track that requires on-demand loading. Example usage: videojs(element, { html5: { preloadTextTracks: false } };
This PR is also a place for discussion around how we want to handle tracks.
Currently, I've changed it so that tracks get loaded on demand, i.e., when you select them to display, and not all at once when the player is loaded.
default
tracks get loaded on player creation, still.The menu should still be showing up because the TextTrack object is being created, just that the cues aren't being populated.
Also, this might be causing issues with chapters as it is right now, but could be fixed by loading those initially along with the default tracks.
This fixex #1913 and related issues.
@dmlap @heff