diff --git a/src/js/player.js b/src/js/player.js index 088a0c8..f51a52d 100644 --- a/src/js/player.js +++ b/src/js/player.js @@ -148,6 +148,14 @@ class APlayer { } }); + // Can seek now + this.on('loadedmetadata', () => { + this.seek(0); + if (!this.paused) { + this.audio.play(); + } + }); + // show audio loaded bar: to inform interested parties of progress downloading the media this.on('canplay', () => { const percentage = this.audio.buffered.length ? this.audio.buffered.end(this.audio.buffered.length - 1) / this.duration : 0; @@ -241,11 +249,6 @@ class APlayer { this.audio.src = audio.url; } } - this.seek(0); - - if (!this.paused) { - this.audio.play(); - } } theme(color = this.list.audios[this.list.index].theme || this.options.theme, index = this.list.index, isReset = true) {