aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/html5.js
diff options
context:
space:
mode:
authorPhilip Giuliani <philip.giuliani@keepinmind.info>2018-05-31 10:17:21 +0200
committerPhilip Giuliani <philip.giuliani@keepinmind.info>2018-05-31 10:17:41 +0200
commit61f4b998e1b9909b30a676463d7afa696299662e (patch)
treea2f6a054cbd2eb0de70d60417f781dfe4e9901af /src/js/html5.js
parent25a319d884dec98fe9929b53d57a7146b11d2e27 (diff)
downloadplyr-61f4b998e1b9909b30a676463d7afa696299662e.tar.lz
plyr-61f4b998e1b9909b30a676463d7afa696299662e.tar.xz
plyr-61f4b998e1b9909b30a676463d7afa696299662e.zip
Wait for the metadata to be loaded before setting the currentTime
Diffstat (limited to 'src/js/html5.js')
-rw-r--r--src/js/html5.js10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/js/html5.js b/src/js/html5.js
index 3818a441..63596cfc 100644
--- a/src/js/html5.js
+++ b/src/js/html5.js
@@ -99,6 +99,13 @@ const html5 = {
// Set new source
player.media.src = supported[0].getAttribute('src');
+ // Restore time
+ const onLoadedMetaData = () => {
+ player.currentTime = currentTime;
+ player.off('loadedmetadata', onLoadedMetaData);
+ };
+ player.on('loadedmetadata', onLoadedMetaData);
+
// Load new source
player.media.load();
@@ -107,9 +114,6 @@ const html5 = {
player.play();
}
- // Restore time
- player.currentTime = currentTime;
-
// Trigger change event
utils.dispatchEvent.call(player, player.media, 'qualitychange', false, {
quality: input,