-
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
Remote Text Tracks Deleted Immediately Because of Asynchronous Nature of src
#4403
Comments
Whoops, that's a total oversight. We should definitely handle this case. There are some versions of 6.x on the CDN, only patch versions have been uploaded: http://vjs.zencdn.net/6.1.0/video.js. Also, since we release to npm, all the files are available on unpkg.com! |
@gkatsev thanks for the quick response. In thinking through this more, I realized that there are other serious consequences of the call to app.player.src('your-url');
app.player.addRemoteTextTrack('your-url');
app.emit('HeyGuysThePlayerStateChanged'); In this scenario where you're sending a notification to the rest of your app saying that the state of the player changed, event handlers could potentially be fired before the player actually has the new state. The naïve way to "fix" this might seem like: app.player.src('your-url');
app.player.addRemoteTextTrack('your-url');
setTimeout(app.emit.bind(app, 'HeyGuysThePlayerStateChanged'), 2); But I don't think we can really guarantee that browsers will execute my app.player.src('your-url');
app.player.addRemoteTextTrack('your-url');
function checkForChange() {
if (player.src() === 'your-url' && checkThatRemoteTextTracksMatchExpectedStateAlso()) {
app.emit('HeyGuysThePlayerStateChanged');
} else {
setTimeout(checkForChange, 1);
}
}
setTimeout(checkForChange, 2); That should work because you keep waiting until the state has actually changed. But that's horrible to have to write. It seems like internally, video.js has this same issue, and it is solved by calling Lines 1622 to 1630 in c31836c
So, the question is: is calling |
Hey, sorry to take to long to reply. Yes, I think |
…to (#4450) We added a feature so that remote text tracks can auto-removed when a source changes. However, in 6.x we changed the source behavior to be asynchronous meaning that some text tracks were accidentally being removed when they weren't supposed to be. For example: ```js var player = videojs('my-player'); player.src({src: 'video.mp4', type: 'video/mp4'}); // set second arg to false so that they get auto-removed on source change player.addRemoteTextTrack({kind: 'captions', src: 'text.vtt', srclang: 'en'}, false); ``` Now when the player loads, this captions track is actually missing because it was removed. Instead of adding auto-removal tracks immediately to the list, wait until we've selected a source before adding them in. Fixes #4403 and #4315.
This should be fixed in 6.2.1, @jthomerson can you try it out? |
Description
If I call
.src({ src: '...' })
and then call.addRemoteTextTrack({ src: '...' }, false)
right after it, my remote text tracks are deleted immediately, and do not appear on the video player. Why? Because the call to.src(...)
is actually asynchronous, and passing thefalse
means "auto cleanup remote text tracks the next time the source changes". See the example below for a more detailed flow description.This did not happen in video.jx 5.x because calls to
.src(...)
were synchronous. You can verify that by replacing the CSS/JS includes below with:I believe the source of the problem to be this line of code:
video.js/src/js/tech/middleware.js
Line 19 in c31836c
One possible fix would be to make the call to
addRemoteTextTrack
asynchronous as well. But that feels a bit like a hack.Steps to reproduce
Use this example page, linking the CSS and JS to a 6x version of video.js. (side point: I can't find 6.x on a CDN, which is what stopped me from making this a jsfiddle)
Results
Expected
Please describe what you expected to see.
Subtitles.
Actual
Please describe what actually happened.
No subtitles.
Error output
If there are any errors at all, please include them here.
Not applicable.
Additional Information
Please include any additional information necessary here. Including the following:
versions
videojs
what version of videojs does this occur with?
6.x
browsers
what browser are affected?
all
OSes
what platforms (operating systems and devices) are affected?
all
plugins
are any videojs plugins being used on the page? If so, please list them below.
none
The text was updated successfully, but these errors were encountered: