From b61ba02f3dbed71f595188d69441132972767eb0 Mon Sep 17 00:00:00 2001 From: Sam Potts Date: Tue, 19 Jun 2018 09:12:21 +1000 Subject: Fix issue with play button not changing state (fixes #1048) --- src/js/ui.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/js/ui.js b/src/js/ui.js index d0b27ae7..34fe7e82 100644 --- a/src/js/ui.js +++ b/src/js/ui.js @@ -135,11 +135,9 @@ const ui = { } // If there's a play button, set label - if (is.nodeList(this.elements.buttons.play)) { - Array.from(this.elements.buttons.play).forEach(button => { - button.setAttribute('aria-label', label); - }); - } + Array.from(this.elements.buttons.play || []).forEach(button => { + button.setAttribute('aria-label', label); + }); // Set iframe title // https://github.com/sampotts/plyr/issues/124 @@ -214,11 +212,9 @@ const ui = { toggleClass(this.elements.container, this.config.classNames.stopped, this.stopped); // Set state - if (is.nodeList(this.elements.buttons.play)) { - Array.from(this.elements.buttons.play).forEach(target => { - target.pressed = this.playing; - }); - } + Array.from(this.elements.buttons.play || []).forEach(target => { + target.pressed = this.playing; + }); // Only update controls on non timeupdate events if (is.event(event) && event.type === 'timeupdate') { -- cgit v1.2.3 From 94055f0772c6c5febcfe1e35714ae3e88afaaf35 Mon Sep 17 00:00:00 2001 From: Albin Larsson Date: Tue, 19 Jun 2018 00:24:27 +0200 Subject: Replace filter()[0] with find() --- src/js/html5.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/js/html5.js b/src/js/html5.js index 6aa96f4c..3c9f1030 100644 --- a/src/js/html5.js +++ b/src/js/html5.js @@ -39,7 +39,7 @@ const html5 = { get() { // Get sources const sources = html5.getSources.call(player); - const [source] = sources.filter(source => source.getAttribute('src') === player.source); + const source = sources.find(source => source.getAttribute('src') === player.source); // Return size, if match is found return source && Number(source.getAttribute('size')); -- cgit v1.2.3 From d72e502107b24a629572f6dcac3fdc4c95ea9001 Mon Sep 17 00:00:00 2001 From: Albin Larsson Date: Tue, 19 Jun 2018 03:34:07 +0200 Subject: Fixes #1044: Don't load the new source if preload is disabled and the current source hasn't been loaded --- src/js/html5.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/js/html5.js b/src/js/html5.js index 3c9f1030..0876211a 100644 --- a/src/js/html5.js +++ b/src/js/html5.js @@ -57,23 +57,25 @@ const html5 = { } // Get current state - const { currentTime, playing } = player; + const { currentTime, paused, preload, readyState } = player.media; // Set new source player.media.src = source.getAttribute('src'); - // Restore time - const onLoadedMetaData = () => { - player.currentTime = currentTime; - }; - player.once('loadedmetadata', onLoadedMetaData); + // Prevent loading if preload="none" and the current source isn't loaded (#1044) + if (preload !== 'none' || readyState) { + // Restore time + player.once('loadedmetadata', () => { + player.currentTime = currentTime; - // Load new source - player.media.load(); + // Resume playing + if (!paused) { + player.play(); + } + }); - // Resume playing - if (playing) { - player.play(); + // Load new source + player.media.load(); } // Trigger change event -- cgit v1.2.3 From 457d112df718c12ed94a19fa4adffa6f8d74e1a3 Mon Sep 17 00:00:00 2001 From: Albin Larsson Date: Tue, 19 Jun 2018 04:03:59 +0200 Subject: Fix #1045: YouTube mutes when seeking after play --- src/js/plugins/youtube.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/js/plugins/youtube.js b/src/js/plugins/youtube.js index 64b6fff7..94ab6dfa 100644 --- a/src/js/plugins/youtube.js +++ b/src/js/plugins/youtube.js @@ -270,8 +270,8 @@ const youtube = { return Number(instance.getCurrentTime()); }, set(time) { - // If paused, mute audio preventively (YouTube starts playing on seek if the video hasn't been played yet). - if (player.paused) { + // If paused and never played, mute audio preventively (YouTube starts playing on seek if the video hasn't been played yet). + if (player.paused && !player.embed.hasPlayed) { player.embed.mute(); } -- cgit v1.2.3