Skip to content
This repository has been archived by the owner on Nov 26, 2021. It is now read-only.

Commit

Permalink
Add live region to inform screen reader users that advert is playing. (
Browse files Browse the repository at this point in the history
…#118)

* Add live region to inform screen reader users that advert is playing.

This is to address issues DAC-USER-VA-T1-01 and DAC-USER-SRJAWS-T1-02 raised by DAC during their accessibility audit.
The issue is that users with screen readers are unable to control the video while adverts are playing, so we add a message here to inform them that it's an advert and encourage them to wait.
  • Loading branch information
alexandercurtis authored and notlee committed Mar 29, 2018
1 parent 6c4501a commit 72d6dd2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
12 changes: 12 additions & 0 deletions main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,17 @@ $o-video-is-silent: true !default;
height: 100%;
}

.o-video__live-region {
position: absolute;
clip: rect(0 0 0 0);
margin: -1px;
border: 0;
overflow: hidden;
padding: 0;
width: 1px;
height: 1px;
white-space: nowrap;
}

$o-video-is-silent: true !global;
}
7 changes: 7 additions & 0 deletions src/js/ads.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,11 @@ class VideoAds {
// Currently not used, could be used in an interval
// const remainingTime = this.adsManager.getRemainingTime();
}

// Users with screen readers will lose control of video while advert is playing,
// so we explain why and encourage them to wait with this message.
this.video.liveRegionEl.innerHTML=`Video will play after ad in ${options.detail.adDuration} seconds`;

break;
}
case google.ima.AdEvent.Type.COMPLETE: {
Expand All @@ -301,6 +306,8 @@ class VideoAds {
if (ad.isLinear()) {
// Would be used to clear the interval
}

this.video.liveRegionEl.innerHTML='';
break;
}

Expand Down
4 changes: 4 additions & 0 deletions src/js/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ class Video {
}

addVideo() {
this.liveRegionEl = document.createElement('div');
this.liveRegionEl.setAttribute('aria-live','assertive');
this.liveRegionEl.classList.add('o-video__live-region');
this.videoEl = document.createElement('video');
this.videoEl.controls = true;
this.videoEl.className = Array.isArray(this.opts.classes) ? this.opts.classes.join(' ') : this.opts.classes;
Expand All @@ -233,6 +236,7 @@ class Video {
this.videoEl.autoplay = this.videoEl.autostart = true;
}

this.containerEl.appendChild(this.liveRegionEl);
this.containerEl.appendChild(this.videoEl);

addEvents(this, ['playing', 'pause', 'ended', 'progress', 'seeked', 'error', 'stalled']);
Expand Down

0 comments on commit 72d6dd2

Please sign in to comment.