-
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
Captions #1736
Captions #1736
Conversation
Currently, the captions only show up if selected via the captions menu. |
Don't auto-add the textTrackDisplay component. Add a 'featuresNativeTrack'. Currently hardcoded to false for everything except the html5 tech. Add textTracks and addTextTrack methods to html5 tech. Proxy player level methods to tech if we're using native tracks. Fix up track menu items to work with spec tracks or vjs tracks.
Also, if text tracks are old and use numerical mode values, use custom tracks. If an html tech is using custom tracks, remove track elements so we don't accidentally show both custom and native captions. Clean up showTextTrack slightly.
textTracks is completely inside of techs but needs to be called manually because techGet requires the tech to be ready. addTextTrack, unfortunately, currently forks. If when called, it doesn't have a tech, it assumes that it's a custom implementation and does the same work that MediaTechController#addTextTrack does. Don't create a flash getter for textTracks.
Load up textTrackDisplay synchronously but have it do no work until the player is ready (see the previous commit).
Add a check that delegates to MediaTechController's methods if we're in Html5 but we are not using native tracks.
@@ -357,6 +357,13 @@ vjs.removeClass = function(element, classToRemove){ | |||
* @private | |||
*/ | |||
vjs.TEST_VID = vjs.createEl('video'); | |||
(function() { |
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.
Is the main reason we need to add IIFEs like this because the dev version doesn't get automatically wrapped in one?
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.
Yes but also to make a new context.
I think I'm starting to understand the reason why there's no removeTextTrack API for the video element. The most common use case for removing tracks is going to be switching sources. When switching sources you would also be removing all source elements from the video element and replacing them with new source elements, so it makes sense to handle tracks the same way. There's no So the primary control mechanism for tracks is really the DOM interface, and So then the key issue here is that if the browser was to provide a removeTextTrack API, when you removed a track from videoEl.textTracks it would have to find it's corresponding track element from the video element and remove it. I expect that modifying DOM elements like that is something browsers try to avoid, at least outside of explicit APIs like removeChild. Looking at it from that perspective (specifically that the DOM interface is the primary one) I think it gives more weight towards @dmlap's suggestions around mimicking that interface, outlined in #1728 part 2. |
@@ -29,6 +33,59 @@ vjs.MediaTechController = vjs.Component.extend({ | |||
} | |||
|
|||
this.initControlsListeners(); | |||
|
|||
if (!this['featuresTextTracks']) { | |||
textTrackDisplay = player.addChild('textTrackDisplay'); |
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.
Another option here would be to have textTrackDisplay always be a child of player, and have it disable itself whenever nativeTextTracks are used. That might be a little cleaner than having a child of player inject a sibling.
As is there might be a bug here. It doesn't look like textTrackDisplay gets removed when this tech is disposed, so the next tech will get loaded and add a second textTrackDisplay.
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.
I believe that the default component functionality takes care of disposing the textTrackDisplay
.
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.
A component will automatically dispose all its children, but textTrackDisplay isn't being added as a child of this tech. When we switch techs the tech gets disposed but the player doesn't, so the textTrackDisplay wouldn't be disposed in that case.
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.
Fixed in 7d702c9
I'm getting this compiler error when I try to build this locally. It looks like that's what's tripping up travis.
|
* Descriptions (not supported yet) - audio descriptions that are read back to the user by a screen reading device | ||
*/ | ||
|
||
var getProp = function(obj, prop) { |
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.
I think this can be removed? It's duplicated here https://github.com/videojs/video.js/pull/1736/files#diff-8169d53aa7eee6cab5f85b6641ef3117R1
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.
getProp should just be removed altogether.
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.
Removed in 33417f6
Clean up text track related listeners.
|
||
options = options || {}; | ||
|
||
player = options.player || { |
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.
Why is this optional? Can this realistically be omitted?
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.
Um... probably not, actually.
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.
Addressed here 78087de, currently throwing but open to other suggestions.
RE: Captions Settings
|
Yeah, captions settings stuff needs to be re-written from scratch. |
all current comments have been addressed (other than the settings menu). Closing this now. We should move forward to the new PR #1749. |
This is the new all encompassing captions PR.
It's still have some issues, like
cuechange
firing unconditionally and some issues with the captions displaying but there won't be much architectural changes to this.I'd like at some point to take all the TextTrack stuff out of videojs and include it as a dependency similar to vttjs.
Things left to do:
cuechange
needs to be updated to only fire once per change. It currently fires a couple of times per change.