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

Combined tracks control #4028

Merged
merged 9 commits into from
Mar 2, 2017
Merged

Combined tracks control #4028

merged 9 commits into from
Mar 2, 2017

Conversation

mister-ben
Copy link
Contributor

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

  • Added a 'TrackButton'
  • Modified the track controls to have a kinds array internally so they can iterate through more than one kind when toggling other tracks' state.
  • Doesn't break the exisiting single-kind controls (in fact fixes an issue that the subtitles menu doesn't update if a subtitle track was showing when captions are enabled)

Requirements Checklist

  • Feature implemented / Bug fixed
  • If necessary, more likely in a feature request than a bug fix
    • Change has been verified in an actual browser (Chome, Firefox, IE)
    • Unit Tests updated or fixed
    • Docs/guides updated
    • Example created (starter template on JSBin)
  • Reviewed by Two Core Contributors

*/
constructor(player, options, ready) {
super(player, options, ready);
this.el_.setAttribute('aria-label', 'Captions Menu');
Copy link
Member

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.

Copy link
Member

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

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.

Copy link
Contributor Author

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.

@@ -67,6 +68,7 @@ ControlBar.prototype.options_ = {
'descriptionsButton',
'subtitlesButton',
'captionsButton',
'tracksButton',
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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?

@OwenEdwards
Copy link
Member

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?

@mister-ben
Copy link
Contributor Author

Agreed, tracksButton is inadequate. I haven't thought of anything better than subCapsButton that that's descriptive and accurate.

@OwenEdwards
Copy link
Member

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".
![2017-02-08_14-09-41]. Thoughts on that?(https://cloud.githubusercontent.com/assets/2245205/22759729/5f11e980-ee08-11e6-8401-c8f9a48c0a44.png)

@mister-ben mister-ben mentioned this pull request Feb 9, 2017
5 tasks
@@ -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') {
Copy link
Member

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.kindsdoesn't get set.

Copy link
Member

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

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

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

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?

@@ -67,6 +68,7 @@ ControlBar.prototype.options_ = {
'descriptionsButton',
'subtitlesButton',
'captionsButton',
'tracksButton',
Copy link
Member

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?

@mister-ben
Copy link
Contributor Author

mister-ben commented Feb 14, 2017

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.

@@ -68,6 +69,7 @@ ControlBar.prototype.options_ = {
'descriptionsButton',
'subtitlesButton',
'captionsButton',
'subCapsButton',
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Urgh, sorry.

}

// Todo
.video-js .vjs-subs-caps-button + .vjs-menu .vjs-captions-menu-item .vjs-menu-item-text:after {
Copy link
Member

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.

Copy link
Contributor Author

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.

@mister-ben mister-ben changed the title WIP: Combined tracks control Combined tracks control Feb 16, 2017
@mister-ben
Copy link
Contributor Author

I think this is in a viable state now, with updated tests

Copy link
Member

@gkatsev gkatsev left a 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_;
Copy link
Member

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_?

Copy link
Contributor Author

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

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?

Copy link
Contributor Author

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.

Copy link
Member

@gkatsev gkatsev left a 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";
Copy link
Member

@gkatsev gkatsev Feb 22, 2017

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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!

@OwenEdwards
Copy link
Member

OwenEdwards commented Feb 23, 2017

My one slight concern about merging this PR is that, while the feature looks great, the dummy WebVTT tracks in the docs/examples/shared folder are just for testing, and aren't really what they say they are. Also, the test HTML file in the sandbox is the only one with a .html extension; we discussed why they have the .example extension a while ago, and I'd love to change it, but we ought to go one way or another with this, for consistency.

@mister-ben
Copy link
Contributor Author

@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.

@gkatsev
Copy link
Member

gkatsev commented Feb 24, 2017

Maybe we should switch the default video to something like elephants dream which has all the tracks? At least for the sandbox?

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

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!

Copy link
Contributor Author

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

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 ;-)>)

Copy link
Contributor Author

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"...)

@gkatsev gkatsev merged commit 74eb5d4 into videojs:master Mar 2, 2017
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.

3 participants