From 21a30f1b6fd3f95550ea37fc610b94ea9e688899 Mon Sep 17 00:00:00 2001 From: Sam Potts Date: Mon, 3 Oct 2016 17:16:05 +1100 Subject: Fixed for array passed to _on and _off --- src/js/plyr.js | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) (limited to 'src/js') diff --git a/src/js/plyr.js b/src/js/plyr.js index 2ce6cd3b..f42e7641 100644 --- a/src/js/plyr.js +++ b/src/js/plyr.js @@ -440,14 +440,14 @@ // Bind event handler function _on(element, events, callback, useCapture) { - if (_is.htmlElement(element)) { + if (!_is.undefined(element)) { _toggleListener(element, events, callback, true, useCapture); } } // Unbind event handler function _off(element, events, callback, useCapture) { - if (_is.htmlElement(element)) { + if (!_is.undefined(element)) { _toggleListener(element, events, callback, false, useCapture); } } @@ -1025,13 +1025,9 @@ } } - // Caption cue change helper event - /*function _captionCueChange() { - _setActiveCueForTrack(this); - }*/ - // Display active caption if it contains text - function _setActiveCueForTrack(track) { + function _setActiveCue(track) { + // Get the track from the event if needed if (_is.event(track)) { track = track.target; } @@ -1094,14 +1090,17 @@ if (!plyr.captionExists) { _toggleClass(plyr.container, config.classes.captions.enabled); } else { + var tracks = plyr.media.textTracks; + // Turn off native caption rendering to avoid double captions // This doesn't seem to work in Safari 7+, so the elements are removed from the dom below - var tracks = plyr.media.textTracks; - for (var x = 0; x < tracks.length; x++) { + [].forEach.call(tracks, function(track) { // Remove the listener to prevent event overlapping - _off(tracks[x], 'cuechange', _setActiveCueForTrack); - tracks[x].mode = 'hidden'; - } + _off(track, 'cuechange', _setActiveCue); + + // Hide captions + track.mode = 'hidden'; + }); // Enable UI _showCaptions(plyr); @@ -1126,11 +1125,11 @@ var track = tracks[config.captions.selectedIndex]; if (track.kind === 'captions' || track.kind === 'subtitles') { - _on(track, 'cuechange', _setActiveCueForTrack); + _on(track, 'cuechange', _setActiveCue); - // if we change the active track while a cue is already displayed we need to update it + // If we change the active track while a cue is already displayed we need to update it if (track.activeCues && track.activeCues.length > 0) { - _setActiveCueForTrack(track); + _setActiveCue(track); } } } else { @@ -1155,15 +1154,15 @@ //According to webvtt spec, line terminator consists of one of the following // CRLF (U+000D U+000A), LF (U+000A) or CR (U+000D) var lineSeparator = '\r\n'; - if(req.indexOf(lineSeparator+lineSeparator) === -1) { - if(req.indexOf('\r\r') !== -1){ + if (req.indexOf(lineSeparator + lineSeparator) === -1) { + if (req.indexOf('\r\r') !== -1) { lineSeparator = '\r'; } else { lineSeparator = '\n'; } } - captions = req.split(lineSeparator+lineSeparator); + captions = req.split(lineSeparator + lineSeparator); for (var r = 0; r < captions.length; r++) { caption = captions[r]; -- cgit v1.2.3 From a17cbb0e8b6e0b2d8fe482f4262bde040dc3e98c Mon Sep 17 00:00:00 2001 From: Darren Anderson Date: Thu, 6 Oct 2016 15:33:49 +0100 Subject: Added .isPaused to API --- src/js/plyr.js | 1 + 1 file changed, 1 insertion(+) (limited to 'src/js') diff --git a/src/js/plyr.js b/src/js/plyr.js index 18099312..1d2cc4f0 100644 --- a/src/js/plyr.js +++ b/src/js/plyr.js @@ -3400,6 +3400,7 @@ isMuted: function() { return plyr.media.muted; }, isReady: function() { return _hasClass(plyr.container, config.classes.ready); }, isLoading: function() { return _hasClass(plyr.container, config.classes.loading); }, + isPaused: function() { return plyr.media.paused; }, on: function(event, callback) { _on(plyr.container, event, callback); }, play: _play, pause: _pause, -- cgit v1.2.3 From f428c3ff8b2bd0cb212f91d456597dc62fcff53b Mon Sep 17 00:00:00 2001 From: Sam Potts Date: Sun, 23 Oct 2016 12:19:39 +1100 Subject: Manually merged #395 --- src/js/plyr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/js') diff --git a/src/js/plyr.js b/src/js/plyr.js index 1d2cc4f0..73389bf2 100644 --- a/src/js/plyr.js +++ b/src/js/plyr.js @@ -3401,7 +3401,7 @@ isReady: function() { return _hasClass(plyr.container, config.classes.ready); }, isLoading: function() { return _hasClass(plyr.container, config.classes.loading); }, isPaused: function() { return plyr.media.paused; }, - on: function(event, callback) { _on(plyr.container, event, callback); }, + on: function(event, callback) { _on(plyr.container, event, callback); return this; }, play: _play, pause: _pause, stop: function() { _pause(); _seek(); }, -- cgit v1.2.3 From a509a5e1bc6a1ada4e56e326f01396292821bf27 Mon Sep 17 00:00:00 2001 From: Sam Potts Date: Sun, 23 Oct 2016 13:48:05 +1100 Subject: v2.0.8 - Added `isPaused()` API method (thanks to @darrena092) - Allowed `.on()` API method to be chainable (thanks to @gurupras) (fixes #357) - Improved the "awful" rendering of captions on small screens in fullscreen mode (fixes #390) - Fix for Firefox VTT compatibility (thanks to @magourex) - Fix for Firefox Developer Edition blank video due to `-webkit-mask-image` issue (fixes #392) - Added Issue and PR templates with the aim of reducing duplicate or duff issues --- src/js/plyr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/js') diff --git a/src/js/plyr.js b/src/js/plyr.js index 73389bf2..703aee9c 100644 --- a/src/js/plyr.js +++ b/src/js/plyr.js @@ -1,6 +1,6 @@ // ========================================================================== // Plyr -// plyr.js v2.0.7 +// plyr.js v2.0.8 // https://github.com/selz/plyr // License: The MIT License (MIT) // ========================================================================== @@ -43,7 +43,7 @@ displayDuration: true, loadSprite: true, iconPrefix: 'plyr', - iconUrl: 'https://cdn.plyr.io/2.0.7/plyr.svg', + iconUrl: 'https://cdn.plyr.io/2.0.8/plyr.svg', clickToPlay: true, hideControls: true, showPosterOnEnd: false, -- cgit v1.2.3 From 08b4c09b896e1ad27c7a7f974e98831eec294019 Mon Sep 17 00:00:00 2001 From: Sam Potts Date: Sun, 23 Oct 2016 15:18:08 +1100 Subject: Temporary patch for the YouTube API issues with `getDuration()` (relates to #374) --- src/js/plyr.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/js') diff --git a/src/js/plyr.js b/src/js/plyr.js index 703aee9c..c2e3a621 100644 --- a/src/js/plyr.js +++ b/src/js/plyr.js @@ -1737,6 +1737,14 @@ _triggerEvent(plyr.media, 'timeupdate'); }, 100); + // Check duration again due to YouTube bug + // https://github.com/Selz/plyr/issues/374 + // https://code.google.com/p/gdata-issues/issues/detail?id=8690 + if (plyr.media.duration !== instance.getDuration()) { + plyr.media.duration = instance.getDuration(); + _triggerEvent(plyr.media, 'durationchange'); + } + break; case 2: -- cgit v1.2.3 From a3ed3093429d5306a89566215207d42a476392d8 Mon Sep 17 00:00:00 2001 From: Sam Potts Date: Sun, 23 Oct 2016 15:18:53 +1100 Subject: v2.0.9 - Temporary patch for the YouTube API issues with `getDuration()` (relates to #374) --- src/js/plyr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/js') diff --git a/src/js/plyr.js b/src/js/plyr.js index c2e3a621..dd14f767 100644 --- a/src/js/plyr.js +++ b/src/js/plyr.js @@ -1,6 +1,6 @@ // ========================================================================== // Plyr -// plyr.js v2.0.8 +// plyr.js v2.0.9 // https://github.com/selz/plyr // License: The MIT License (MIT) // ========================================================================== @@ -43,7 +43,7 @@ displayDuration: true, loadSprite: true, iconPrefix: 'plyr', - iconUrl: 'https://cdn.plyr.io/2.0.8/plyr.svg', + iconUrl: 'https://cdn.plyr.io/2.0.9/plyr.svg', clickToPlay: true, hideControls: true, showPosterOnEnd: false, -- cgit v1.2.3