diff options
author | Albin Larsson <mail@albinlarsson.com> | 2018-06-19 03:34:07 +0200 |
---|---|---|
committer | Albin Larsson <mail@albinlarsson.com> | 2018-06-19 03:39:18 +0200 |
commit | d72e502107b24a629572f6dcac3fdc4c95ea9001 (patch) | |
tree | 0a554a5f69134f1ec232b85c541a9aa9520b0cc9 /src/js/html5.js | |
parent | 94055f0772c6c5febcfe1e35714ae3e88afaaf35 (diff) | |
download | plyr-d72e502107b24a629572f6dcac3fdc4c95ea9001.tar.lz plyr-d72e502107b24a629572f6dcac3fdc4c95ea9001.tar.xz plyr-d72e502107b24a629572f6dcac3fdc4c95ea9001.zip |
Fixes #1044: Don't load the new source if preload is disabled and the current source hasn't been loaded
Diffstat (limited to 'src/js/html5.js')
-rw-r--r-- | src/js/html5.js | 24 |
1 files changed, 13 insertions, 11 deletions
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 |