Skip to content
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

Update vttjs #4115

Merged
merged 7 commits into from
Feb 27, 2017
Merged

Update vttjs #4115

merged 7 commits into from
Feb 27, 2017

Conversation

gkatsev
Copy link
Member

@gkatsev gkatsev commented Feb 21, 2017

Fixes #4093

@justinanastos
Copy link
Contributor

justinanastos commented Feb 22, 2017

@gkatsev I find that this fixes the issue I'd seen previously in #4093. I see this is targeted at master, will this be applied to 5.x as well?

@gkatsev
Copy link
Member Author

gkatsev commented Feb 22, 2017

Yup, I'll make another PR against 5.x when this is complete. Thanks for verifying that it works for you!

@justinanastos
Copy link
Contributor

You're welcome @gkatsev !

justinanastos added a commit to justinanastos/videojs-contrib-dash that referenced this pull request Feb 22, 2017
video.js will try to load `vtt.js` internally and override
`window.VTTCue`. This will break text tracks in dashjs in Chrome
beacuse the native `TextTrack.addCue()`` function expects a
native `VTTCue()` as it's first argument. If we use the `vtt.js`
shimmed version of `VTTCue`, then all calls to `addCue()` will
throw an error. This will silently kill playback with using
fragmented text captions. If we add a truthy value to for
`vtt.js` in `options`, then `video.js` will try to load this url
and use that instead of it's internal shim mechanism. Nothing
will load, and `video.js` won't try to apply it's own version of
`vtt.js` to `window`. This will prevent tracks from breaking in
Chrome. We'll provide a space beacuse this won't throw an error
or try to actually load anything and it will prevent video.js
from breaking dashjs.

This can be removed when
videojs/video.js#4115 is applied to
[email protected].
@gkatsev gkatsev mentioned this pull request Feb 23, 2017
let cue = _cue;

if (!(_cue instanceof window.vttjs.VTTCue)) {
cue = new window.vttjs.VTTCue(_cue.startTime, _cue.endTime, _cue.text);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be possible/better to expose this on videojs rather than window?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's more or less exposed globally right now plus we've expected it to be exposed. For the 5.x version, we definitely should keep it exposed on window because it'll be easier to make it backwards compat.
For this PR, we could look into making a version of vttjs that doesn't bind itself to window. Though, I think it should be done as a separate PR rather than part of this work.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My feeling here is that vttjs is kind of its own thing - we just use it and it should stand alone more or less.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@misteroneill sort of. Given that we're using a custom fork, we can do what we want with it at this point.

The only thing I can imagine that would be tricky to get right to have vttjs not export itself globally is getting the novtt build working correctly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im open to doing it in another PR

@@ -336,7 +336,17 @@ class TextTrack extends Track {
* @param {TextTrack~Cue} cue
* The cue to add to our internal list
*/
addCue(cue) {
addCue(_cue) {
let cue = _cue;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we change this to cueCopy and change _cue back to just cue?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could. I just thought it would be better to leave the rest of the code as is and keep the change relatively self-contained.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that it's more a self documenting code change that would be worth doing, as _cue doesn't really have any significance to tell you what it actually is.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about naming it originalCue?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure that works too

@gkatsev gkatsev merged commit 96a387f into master Feb 27, 2017
@gkatsev gkatsev deleted the vttjs branch February 27, 2017 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants