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

Captions #1736

Closed
wants to merge 81 commits into from
Closed

Captions #1736

wants to merge 81 commits into from

Conversation

gkatsev
Copy link
Member

@gkatsev gkatsev commented Dec 10, 2014

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:

  • A whole bunch more tests.
  • cuechange needs to be updated to only fire once per change. It currently fires a couple of times per change.
  • When adding a cue to a track programmatically, it needs to remove that cue from other text tracks if it existed in any other track.
  • The menus don't work great on mobile devices. Particularly, with respect to hiding the menu after usage.

@gkatsev
Copy link
Member Author

gkatsev commented Dec 10, 2014

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() {
Copy link
Member

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?

Copy link
Member Author

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.

@heff
Copy link
Member

heff commented Dec 16, 2014

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 videoEl.sources property like videoEl.textTracks, so this isn't an issue with sources.

So the primary control mechanism for tracks is really the DOM interface, and addTextTrack is a nice to have add-on that's really meant to allow for other dynamic interactions, not captions (even though it's possible). This kind of explains the lack of the src option in addTextTrack.

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');
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in 7d702c9

@heff
Copy link
Member

heff commented Dec 16, 2014

I'm getting this compiler error when I try to build this locally. It looks like that's what's tripping up travis.

build/files/combined.video.js:8588: ERROR - Variable getProp first declared in build/files/combined.video.js
var getProp = function(obj, prop) {

* Descriptions (not supported yet) - audio descriptions that are read back to the user by a screen reading device
*/

var getProp = function(obj, prop) {
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

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.

Copy link
Member Author

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 || {
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

Um... probably not, actually.

Copy link
Member Author

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.

@heff
Copy link
Member

heff commented Dec 17, 2014

RE: Captions Settings

  • I think it'd be better if the color selection actually showed the color instead of the word. I like the PBS version best, but the BC color dropdown could work too.
  • It'd be nice if you could see what the captions look like as you're changing the settings. It shouldn't be too difficult to create an example caption above the settings.

35e9454e-4f37-461f-85a4-618abe63adc3

@gkatsev
Copy link
Member Author

gkatsev commented Dec 17, 2014

Yeah, captions settings stuff needs to be re-written from scratch.

@gkatsev gkatsev mentioned this pull request Dec 17, 2014
3 tasks
@gkatsev
Copy link
Member Author

gkatsev commented Dec 23, 2014

all current comments have been addressed (other than the settings menu). Closing this now. We should move forward to the new PR #1749.

@gkatsev gkatsev closed this Dec 23, 2014
@gkatsev gkatsev deleted the text-tracks-api branch August 12, 2015 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants