-
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
Combined tracks control #4028
Combined tracks control #4028
Conversation
*/ | ||
constructor(player, options, ready) { | ||
super(player, options, ready); | ||
this.el_.setAttribute('aria-label', 'Captions Menu'); |
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 aria-label assignment should be removed after #4034 lands.
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.
That PR was landed. This PR probably needs to be rebased against master.
* @type {string} | ||
* @private | ||
*/ | ||
TracksButton.prototype.controlText_ = 'Captions'; |
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 text will need to change depending on North America/Rest Of the World, as with the icon for the control.
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.
And a little more complex to localise if the string needs to be localised as captions or subtitles here, but specifically as captions on the captions-only control, which might be translated as "subtitles for the hard of hearing".
This would be easier if we used something like CAPTIONS_OR_SUBTITLES as keys in the translations json and included en.json in the player.
src/js/control-bar/control-bar.js
Outdated
@@ -67,6 +68,7 @@ ControlBar.prototype.options_ = { | |||
'descriptionsButton', | |||
'subtitlesButton', | |||
'captionsButton', | |||
'tracksButton', |
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 assume that the default Control Bar won't have subtitlesButton
, captionsButton
and tracksButton
- it'll be either/or?
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.
Left in for testing to make sure they don't break each other, but I don't see a reason for them to be used like that for real.
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.
What about removing from here and updating the combined-tracks test page to include all the separate caption buttons in the control bar as a default config?
To me, the name "tracksButton" is confusing because we have so many different kinds of tracks now, including (non-text) audio tracks. How about "subsCapsButton", something like that? |
Agreed, |
Looking at the way Safari handles this for videos with text tracks and an audio description track, it all gets rolled together with the Subtitles icon for the menu, then options for "Audio Track" and "Subtitles". |
@@ -51,7 +58,7 @@ class OffTextTrackMenuItem extends TextTrackMenuItem { | |||
for (let i = 0, l = tracks.length; i < l; i++) { | |||
const track = tracks[i]; | |||
|
|||
if (track.kind === this.track.kind && track.mode === 'showing') { | |||
if ((this.track.kinds.indexOf(track.kind) > -1) && track.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 line is erroring out for me. this.track.kinds
doesn't get set.
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.
should it be this.options_.kinds
?
} | ||
|
||
// Todo | ||
.video-js .vjs-tracks-button .vjs-captions-menu-item::after { |
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.
we should continue using single colon for pseudo elements.
content: none; | ||
} | ||
|
||
.video-js:lang(en-US) .vjs-tracks-button .vjs-subtitles-menu-item::after, |
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 should be en
?
} | ||
|
||
// Todo | ||
.video-js .vjs-tracks-button .vjs-captions-menu-item::after { |
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.
so, captions
are always indicated as [cc]
and subs are only indicated as such in en
and fr-CA
locales?
src/js/control-bar/control-bar.js
Outdated
@@ -67,6 +68,7 @@ ControlBar.prototype.options_ = { | |||
'descriptionsButton', | |||
'subtitlesButton', | |||
'captionsButton', | |||
'tracksButton', |
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.
What about removing from here and updating the combined-tracks test page to include all the separate caption buttons in the control bar as a default config?
6c3dd28
to
46a7035
Compare
Updated and rebased. I've left the old controls in for the moment as several tests need to be modified to take them out of the default ControlBar. To distinguish captions in the menu, I've added the CC icon rather than "[cc]" text now, and for any locale - thoughts on whether that's readable enough? The material cc icon isn't great at small sizes. |
src/js/control-bar/control-bar.js
Outdated
@@ -68,6 +69,7 @@ ControlBar.prototype.options_ = { | |||
'descriptionsButton', | |||
'subtitlesButton', | |||
'captionsButton', | |||
'subCapsButton', |
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 be subsCapsButton
took me forever to figure out why it wasn't working for me, haha
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.
Urgh, sorry.
src/css/components/_subs-caps.scss
Outdated
} | ||
|
||
// Todo | ||
.video-js .vjs-subs-caps-button + .vjs-menu .vjs-captions-menu-item .vjs-menu-item-text:after { |
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 be vertical-align: baseline
so it's all on the same line.
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.
vertical-align: bottom
seems to work better.
46a7035
to
5e5eae1
Compare
I think this is in a viable state now, with updated tests |
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.
One thing I just realized is that after this, the Captions settings dialog would need to be updated. Currently, it returns focus directly to the captionsbutton, but would need to change slightly with this change, so, return to this menu button if it exists, otherwise, to the captions button, if that exists.
* @type {string} | ||
* @private | ||
*/ | ||
SubsCapsButton.prototype.controlText_ = this.label_; |
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.
Should this just be subtitles
as a default and then in here we just do this.controlText_ = this.label_
?
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.
The controlText wasn't getting set at all, that approach fixes it.
|
||
// Although North America uses "captions" in most cases for | ||
// "captions and subtitles" other locales use "subtitles" | ||
this.label_ = 'subtitles'; |
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.
Does this need to be localized?
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 gets concatenated into 'captions setttings' and 'captions off', which do get localised.
c701aad
to
e876942
Compare
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.
Looks like the cc icon in the menu is read out by the screen reader, we should wrap it in the icon-placeholder span like in other components.
} | ||
|
||
.video-js .vjs-subs-caps-button + .vjs-menu .vjs-captions-menu-item .vjs-menu-item-text:after { | ||
content: " \f10d"; |
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 is showing up in the screen reader. We need to add an icon placeholder span.
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.
Good catch @gkatsev !! I haven't had a chance to check this, but is there some controlText
for the icon, so that something is read out by a screen reader instead of the icon? Otherwise, that's an #a11y violation too - information which is conveyed visually, but not to SR users.
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.
OK, this can't be done with CSS alone 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.
Yeah, I don't think this is possible to do in CSS. @mister-ben do you think you can get to it this week? Otherwise, I'm thinking we can merge it in as is and I or someone else can tackle it.
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 probably won't have a chance to look at this now before the end of next week.
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.
Cool, thanks @mister-ben this is pretty awesome as it is. We'll take care of this final piece!
My one slight concern about merging this PR is that, while the feature looks great, the dummy WebVTT tracks in the |
@OwenEdwards good point, I'll clean that up. The Oceans video doesn't really lend itself to a meaningful demo of captions and subtitles at all though. |
Maybe we should switch the default video to something like elephants dream which has all the tracks? At least for the sandbox? |
sandbox/combined-tracks.html.example
Outdated
<track kind="subtitles" src="../docs/examples/shared/example-subtitles-fr.vtt" srclang="fr" label="French"></track><!-- Tracks need an ending tag thanks to IE9 --> | ||
<track kind="subtitles" src="../docs/examples/shared/example-subtitles-de.vtt" srclang="de" label="German"></track><!-- Tracks need an ending tag thanks to IE9 --> | ||
<video id="vid1" class="video-js vjs-default-skin" lang="en" controls preload="auto" width="640" height="264" poster="http://vjs.zencdn.net/v/oceans.png"> | ||
<source src="//d2zihajmogu5jn.cloudfront.net/elephantsdream/ed_hd.mp4" type="video/mp4"> |
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.
Nice! I guess I ought to move the Descriptions example to use this Cloudfront URL!
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 is the content used at videojs.com/advanced
@@ -0,0 +1,102 @@ | |||
/** | |||
* @file tracks-button.js |
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.
Just noticed - this file name needs updating. (<Captain Pedantic, at you're service ;-)>)
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.
Ah yes. (Not rising to "you're"...)
Description
Puts captions and subtitles in a single control. Tidier UI and less confusing for those who don't generally distinguish between those types. Captions have '[CC]' appended - CSS currently, but this should be localisable.
For now, there's an example in /sandbox.
Specific Changes proposed
kinds
array internally so they can iterate through more than one kind when toggling other tracks' state.Requirements Checklist