diff options
author | Sam Potts <sam@potts.es> | 2018-06-19 19:24:47 +1000 |
---|---|---|
committer | Sam Potts <sam@potts.es> | 2018-06-19 19:24:47 +1000 |
commit | bb546fe43fc6537a4dc0a350a7aa4260a3f97b1d (patch) | |
tree | b70095eb74061a7a4089ecc043c0e4b27c0f934b /src/js/html5.js | |
parent | 9e1218547b18e87921d0bd95d259cac4fe538c61 (diff) | |
parent | 52ea5bd0ab211cc18e7d1f6de06a78d805a94b62 (diff) | |
download | plyr-bb546fe43fc6537a4dc0a350a7aa4260a3f97b1d.tar.lz plyr-bb546fe43fc6537a4dc0a350a7aa4260a3f97b1d.tar.xz plyr-bb546fe43fc6537a4dc0a350a7aa4260a3f97b1d.zip |
Merge branch 'develop' into a11y-improvements
# Conflicts:
# dist/plyr.js.map
# dist/plyr.min.js
# dist/plyr.min.js.map
# dist/plyr.polyfilled.js.map
# dist/plyr.polyfilled.min.js
# dist/plyr.polyfilled.min.js.map
Diffstat (limited to 'src/js/html5.js')
-rw-r--r-- | src/js/html5.js | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/js/html5.js b/src/js/html5.js index 6aa96f4c..0876211a 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')); @@ -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 |