Skip to content

Commit

Permalink
js to announce at oncuechange
Browse files Browse the repository at this point in the history
  • Loading branch information
haltersweb committed Aug 1, 2017
1 parent 9b4eac7 commit 11b7b19
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
20 changes: 20 additions & 0 deletions js/web-vtt-player.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*global
jQuery, NAME, console
*/
/**
* WebVTT player
*/
(function ($, NAME, console) {
'use strict';
var videoElement = document.querySelector('video');
var textTracks = videoElement.textTracks;
var textTrack = textTracks[0];
var $ariaContainer = $('[aria-live="polite"]');
textTrack.oncuechange = function () {
//"this" is a textTrack
if (this.activeCues[0]) {
console.log(this.activeCues[0].text);
NAME.access.announcements($ariaContainer, this.activeCues[0].text);
}
};
}(jQuery, NAME, console));
12 changes: 6 additions & 6 deletions video/ski-jumps.vtt
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
WEBVTT
00:00:21.683 --> 00:00:23.183
00:00:21.683 --> 00:00:22.000
Anders Johnson, USA, prepares to jump.

00:00:25.783 --> 00:00:27.283
00:00:25.783 --> 00:00:26.000
Johnson starts down ramp.

00:00:30.783 --> 00:00:32.283
00:00:30.783 --> 00:00:31.000
Johnson launches from ramp.

00:00:31.283 --> 00:00:33.783
00:00:31.283 --> 00:00:32.000
55.2 miles per hour.

00:00:34.433 --> 00:00:36.933
00:00:34.433 --> 00:00:35.000
Johnson lands.

00:00:42.250 --> 00:00:44.750
00:00:42.250 --> 00:00:43.000
95.5 meters jumped.
1 change: 1 addition & 0 deletions web-vtt-player.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ <h1>Lorem ipsum dolor sit amet</h1>
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="js/namespacing.js"></script>
<script type="text/javascript" src="js/accessibility-helpers.js"></script>
<script type="text/javascript" src="js/web-vtt-player.js"></script>
</body>
</html>

0 comments on commit 11b7b19

Please sign in to comment.