diff options
author | Sam Potts <me@sampotts.me> | 2015-08-08 15:16:42 +1000 |
---|---|---|
committer | Sam Potts <me@sampotts.me> | 2015-08-08 15:16:42 +1000 |
commit | f3c324038f0afca22097ae4c6c1ea5e1308616f0 (patch) | |
tree | a6ded4c6262775ea082793658a103db3a6296755 /src/js/plyr.js | |
parent | 34c9bdc84ccba10e54c2f27ca2322f478e40a758 (diff) | |
download | plyr-f3c324038f0afca22097ae4c6c1ea5e1308616f0.tar.lz plyr-f3c324038f0afca22097ae4c6c1ea5e1308616f0.tar.xz plyr-f3c324038f0afca22097ae4c6c1ea5e1308616f0.zip |
ARIA improvements for caption reading
Diffstat (limited to 'src/js/plyr.js')
-rw-r--r-- | src/js/plyr.js | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/js/plyr.js b/src/js/plyr.js index a94d67ed..a1db3e3e 100644 --- a/src/js/plyr.js +++ b/src/js/plyr.js @@ -1,6 +1,6 @@ // ========================================================================== // Plyr -// plyr.js v1.3.0 +// plyr.js v1.3.1 // https://github.com/selz/plyr // License: The MIT License (MIT) // ========================================================================== @@ -640,17 +640,19 @@ } } + // Clear the caption + player.captionsContainer.innerHTML = ""; + // Check if the next caption is in the current time range if (player.media.currentTime.toFixed(1) >= _timecodeMin(player.captions[player.subcount][0]) && player.media.currentTime.toFixed(1) <= _timecodeMax(player.captions[player.subcount][0])) { player.currentCaption = player.captions[player.subcount][1]; - // Render the caption - player.captionsContainer.innerHTML = player.currentCaption.trim(); - } - else { - // Clear the caption - player.captionsContainer.innerHTML = ""; + // Render the caption (only if changed) + var content = player.currentCaption.trim(); + if(player.captionsContainer.innerHTML != content) { + player.captionsContainer.innerHTML = content; + } } } @@ -1019,7 +1021,7 @@ function _setupCaptions() { if(player.type === "video") { // Inject the container - player.videoContainer.insertAdjacentHTML("afterbegin", "<div class='" + config.selectors.captions.replace(".", "") + "' aria-live='assertive'><span></span></div>"); + player.videoContainer.insertAdjacentHTML("afterbegin", "<div class='" + config.selectors.captions.replace(".", "") + "' aria-live='assertive' aria-relevant='additions text'><span></span></div>"); // Cache selector player.captionsContainer = _getElement(config.selectors.captions).querySelector("span"); |