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

Replace Accessible Media Player with pure Youtube embed iframe #908

Merged
merged 3 commits into from
Jul 22, 2019

Conversation

kr8n3r
Copy link
Contributor

@kr8n3r kr8n3r commented Jun 5, 2019

What

Replaces the Accessible Media Player with a pure Youtube iframe player. This won't work on GOV.UK until the content security policy has been updated to allow youtube-nocookie.com

Why

There are a number of accessibility issues with the current video player, so other shortlisted players were prototyped and reviewed. The recommendation was to use the Youtube player with some tweaks to make it more accessible:

  • Add a title attribute to the iframe, taken from the fallback link text,
  • Disable option to allow single key shortcuts (disablekb) due to WCAG SC 2.1.4
  • use the no-cookie version

Before (Nomensa)

Screen Shot 2019-07-08 at 15 54 06

Screen Shot 2019-07-08 at 15 54 11

After (Youtube)

Screen Shot 2019-07-08 at 15 53 40

Screen Shot 2019-07-08 at 15 53 56

Examples

Notes

This PR also:

  • rewrites the video player code so there is no dependency on jQuery or jQuery UI

Accessibility Testing of the Youtube player

Summary

Work by @selfthinker

I have implemented all 4 contending video players (Plyr, Able Player, MediaElement.js and Video.js) plus the default YouTube player and looked a bit deeper into things, especially accessibility.

There are a couple of things which all the other players inherit from YouTube. I've only tested YouTube videos with them as that is where the majority of GOV.UK videos are hosted (or maybe even 100% of them?).

Keyboard access

The YouTube video starts with an image with the generic name "photo image of" that is linked to the channel and then a hidden heading with the name of the channel that is also linked to the channel. That means if you navigate the page without a screen reader, the second tab within the iframe is always hidden. If you navigate the page with a screen reader, the first link never makes sense and the second link rarely makes sense, depending on how well the channel is named, although it always misses the information that it is the name of the channel.

It's nice that YouTube and Able Player show labels for most controls when they have focus or when you hover over them. That way it will be clearer for people with cognitive impairments. Plyr has a setting that would show them as well.

The focus ring on some of MediaElement.js's controls is quite faint.

All video players keep keyboard focus within the fullscreen view and loop to the top when you've reached the end of that screen.

Most of the players have keyboard shortcuts. YouTube uses a single key, which would be against WCAG SC 2.1.4, but that can be disabled. Plyr only uses such shortcuts when the focus is on the player, but that can also be disabled. And Able Player uses modifier keys which can also be changed, so it is never a letter just on its own.

Screen readers

I have so far tested with NVDA in Firefox and VoiceOver on iOS.
It is interesting how the various players announce that there is a video. The only way how you might know there is one with Plyr (and also the current Nomensa player) is because you will stumble upon a "play button". Not great.

YouTube is a bit better as at least you will know there is a frame (whatever might be in it). Mediaplayer.js has the words "video player" just before it and has given the player a role of "application" with the same title, and Able Player has a heading saying "media player". Much better.

All players have some kind of feedback after clicking the play button to announce that the button has changed to a pause button.

Except Plyr gives no feedback at all and even says "button play" after the button has visibly changed to a pause button. YouTube adds the letter "k" which will probably be confusing to screen reader users. On the tooltip the "k" is in brackets which makes it a bit clearer that it's the keyboard shortcut. Able Player goes a bit further and doesn't just announce what the button was changed to but also what clicking it has done to the video, i.e. "pause playing", which I find a bit confusing.

Some labels in the YouTube player are announced after the button, which is confusing. The amount of subscribers is a hidden heading, also confusing. The Plyr player often doesn't provide any feedback after activating a control, which is especially confusing when you are supposed to do something afterwards as in a dropdown menu.

MediaElement.js has half a keyboard trap. When a video has started the up and down arrows turn the volume up and down but cannot be used for the standard NVDA navigation. Tabbing still works, though.

All players show the "related videos" etc including the close button for those when pausing, but Plyr and MediaElement.js doesn't allow you to interact with them in any way, neither via clicking nor tabbing or via navigating with a screen reader. That means there is some functionality visible which cannot be accessed at all. Not good.

All players use the internal iOS video player (although that is often configurable) when used in Safari on iOS. Only Plyr doesn't do that. Plyr's fullscreen implementation still allows you to navigate the rest of the page with VoiceOver, which can be disorientating.
Voice control

I only tested with Windows Speech Recognition as I was testing when I was working from home and didn't have access to Dragon. I will re-test this with Dragon when I'm in the office.
I'm not too familiar with voice control tools, so might easily have missed something.

I could get every player to work with either "play" or "click play" or "play video" except Able Player. It wasn't working most of the time, it seems to only work with "click" when already hovering over the controls. ("Mousegrid" always works, though.)

I had trouble getting Plyr to pause. The YouTube player seemed to work best in this case.

Changing colours

None of the players are usable at all when changing colours in Firefox. Most elements are completely invisible.

Colours are not great but usable when changing colours via the Windows "high contrast" settings. Only MediaElement.js in IE11 is mostly invisible.

Captions

The only players which support switching captions on and off when they are hosted on YouTube are the YouTube player and Able Player.

Browser tests

Everything works in our supported browsers. In order for Plyr to work in IE11, we would need to implement a polyfill which I haven't bothered with for this test. So, Plyr on my playground won't work in IE11 but adding support is possible.

MediaElement.js on my playground isn't responsive. But there is a responsive setting which doesn't seem to be the default.

Conclusion

Just judging by these findings, Able Player or the YouTube player seem to be the best choice.

The question is, how much better is Able Player and in what areas that might justify choosing it over the native YouTube player? It seems to be better for screen reader users but worse for voice control users. It has support for transcripts (even interactive ones), audio descriptions (text-based or audio/video-based) and sign language (via synchronising a second video). But which of those would we actually use?
As far as I can see, both players would fail WCAG but the only proper barrier is the voice control issue with Able Player. (And invisible controls when changing colours, but all players have that issue.)

Discussion

Additionally, we'd like to add a visually hidden heading before the iframe so it's clearer to screen reader users that there is a video, e.g. "Video player".

Issue is, the heading level needs to fit into the heading hierarchy (e.g. an h2 if the heading before is an h1, an h3 if the heading before is an h2, etc, but I think we cannot programmatically establish the heading before.

Youtube Iframe API implementation

Trello Cards

@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-908 June 5, 2019 13:14 Inactive
@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-908 June 5, 2019 13:35 Inactive
@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-908 June 5, 2019 13:45 Inactive
@kr8n3r kr8n3r force-pushed the update-govspeak-youtube-enhancement branch from 744bd86 to 2eae89d Compare June 5, 2019 13:53
@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-908 June 5, 2019 13:53 Inactive
@kr8n3r kr8n3r force-pushed the update-govspeak-youtube-enhancement branch from 2eae89d to a023337 Compare June 5, 2019 14:18
@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-908 June 5, 2019 14:19 Inactive
@kr8n3r kr8n3r force-pushed the update-govspeak-youtube-enhancement branch from a023337 to cccae14 Compare June 5, 2019 14:23
@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-908 June 5, 2019 14:26 Inactive
@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-908 June 5, 2019 15:43 Inactive
@kr8n3r kr8n3r changed the title Replace Nomensa player with Youtube embed Replace Nomensa player with pure Youtube embed iframe Jun 5, 2019
@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-908 June 5, 2019 16:09 Inactive
@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-908 June 5, 2019 16:13 Inactive
@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-908 June 5, 2019 21:06 Inactive
@kr8n3r kr8n3r changed the title Replace Nomensa player with pure Youtube embed iframe Replace Accessible Media Player with pure Youtube embed iframe Jun 5, 2019
@kr8n3r kr8n3r force-pushed the update-govspeak-youtube-enhancement branch from 42f1ea2 to 6281d77 Compare June 5, 2019 21:48
@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-908 June 5, 2019 21:48 Inactive
@kr8n3r kr8n3r force-pushed the update-govspeak-youtube-enhancement branch from 6281d77 to e14f62d Compare June 5, 2019 21:51
@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-908 June 5, 2019 21:51 Inactive
@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-908 June 6, 2019 12:54 Inactive
@kr8n3r kr8n3r force-pushed the update-govspeak-youtube-enhancement branch from 3e5ffe7 to 9f2dd65 Compare June 6, 2019 13:20
@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-908 June 6, 2019 13:21 Inactive
@kevindew
Copy link
Member

kevindew commented Jun 6, 2019

@kr8n3r woop this is an exciting change - be glad to say goodbye to the extra dependencies.

As part of your checks for whether this is good to merge could you co-ordinate with Publishing Workflow team (myself or @alex-ju are good candidates) so we can check it works in our app still. We use it to preview documents and need to re-initialise the component each preview. I ask this because it was quite delicate getting the original version to work with this. Thanks.

@kr8n3r
Copy link
Contributor Author

kr8n3r commented Jun 6, 2019

@kevindew yeah will check with the team once I have it in a state that's passing test and is ready for review.

@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-908 June 6, 2019 13:48 Inactive
@kr8n3r kr8n3r force-pushed the update-govspeak-youtube-enhancement branch from 46358c4 to 9f2dd65 Compare June 6, 2019 13:56
@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-908 June 6, 2019 13:56 Inactive
@bevanloon bevanloon temporarily deployed to govuk-publishing-compon-pr-908 July 12, 2019 11:48 Inactive
@vanitabarrett vanitabarrett force-pushed the update-govspeak-youtube-enhancement branch from 1f90ece to 85744c5 Compare July 12, 2019 11:53
@bevanloon bevanloon temporarily deployed to govuk-publishing-compon-pr-908 July 12, 2019 11:53 Inactive
@vanitabarrett vanitabarrett force-pushed the update-govspeak-youtube-enhancement branch from 85744c5 to fc77062 Compare July 12, 2019 12:06
@bevanloon bevanloon temporarily deployed to govuk-publishing-compon-pr-908 July 12, 2019 12:06 Inactive
@bevanloon bevanloon temporarily deployed to govuk-publishing-compon-pr-908 July 12, 2019 12:11 Inactive
@vanitabarrett vanitabarrett force-pushed the update-govspeak-youtube-enhancement branch from 3ed2886 to e0dbf03 Compare July 12, 2019 12:20
@bevanloon bevanloon temporarily deployed to govuk-publishing-compon-pr-908 July 12, 2019 12:20 Inactive
@vanitabarrett vanitabarrett force-pushed the update-govspeak-youtube-enhancement branch from e0dbf03 to 336051c Compare July 12, 2019 12:53
@bevanloon bevanloon temporarily deployed to govuk-publishing-compon-pr-908 July 12, 2019 12:53 Inactive
@vanitabarrett vanitabarrett force-pushed the update-govspeak-youtube-enhancement branch from 336051c to 8e0bc4f Compare July 12, 2019 12:58
@bevanloon bevanloon temporarily deployed to govuk-publishing-compon-pr-908 July 12, 2019 12:58 Inactive
Copy link
Member

@kevindew kevindew left a comment

Choose a reason for hiding this comment

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

Looks good to me. I'll just give it a final test run on Content Publisher before approving.

Copy link
Member

@kevindew kevindew left a comment

Choose a reason for hiding this comment

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

Worked fine on CP 🎉

@kr8n3r
Copy link
Contributor Author

kr8n3r commented Jul 15, 2019

thanks everyone for taking this on and making it solid 👍

@chao-xian chao-xian force-pushed the update-govspeak-youtube-enhancement branch from 8e0bc4f to 9206142 Compare July 17, 2019 11:29
@bevanloon bevanloon temporarily deployed to govuk-publishing-compon-pr-908 July 17, 2019 11:29 Inactive
@vanitabarrett vanitabarrett force-pushed the update-govspeak-youtube-enhancement branch from 9206142 to da24ebc Compare July 22, 2019 09:01
@bevanloon bevanloon temporarily deployed to govuk-publishing-compon-pr-908 July 22, 2019 09:01 Inactive
kr8n3r and others added 3 commits July 22, 2019 09:02
There are a number of accessibility issues with the current video
player, so a prototype of shortlisted players was reviewed against
the criteria in https://docs.google.com/document/d/1ZhrZH-nKCXs-uMz8HIXPx7FgAs4p3fsrmNMItDj_dt0/edit and the recommendation was to use just the Youtube iframe player with some tweaks:

- Add a title attribute to the iframe, taken from the fallback link text,
- Disable option to allow single key shortcuts (disablekb) due to WCAG SC 2.1.4
- use the no-cookie version

This commit also:

- Avoids the YoutubeLinkEnhancement class having to be concerned with jQuery
- Does the campaign cookie check before proceeding at all with any embeds (previously it checked this on each loop iteration)
Removes the Nomensa player Javascript, uneeded jQuery UI dependency and updates mentions of the
Nomensa Accessible Player to reference the new Youtube player.
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.

7 participants