From 0543efccd8b5c2222987bdffe49283e9f45b0b82 Mon Sep 17 00:00:00 2001 From: Harrison Deng Date: Sun, 17 Apr 2022 01:30:21 -0500 Subject: [PATCH] Added sync check to song player. --- src/player/PlaylistSong.js | 2 +- src/player/SongPlayer.js | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/player/PlaylistSong.js b/src/player/PlaylistSong.js index 492099a..3c3c849 100644 --- a/src/player/PlaylistSong.js +++ b/src/player/PlaylistSong.js @@ -51,7 +51,7 @@ export default class PlayListSong { this._audio.addEventListener("canplaythrough", () => { this.ready = true; - if (onReady) { + if (onReady && this.isAudioInstantiated()) { onReady(this._audio); } }); diff --git a/src/player/SongPlayer.js b/src/player/SongPlayer.js index f7f1fd9..3418da7 100644 --- a/src/player/SongPlayer.js +++ b/src/player/SongPlayer.js @@ -105,7 +105,6 @@ export default class SongPlayer { playCurrent() { this.getCurrentSong().getAudio((audio) => { - // TODO: May need to perform synchronization check to see if this is still the song to be played. audio.volume = this._volume; audio.play(); }); @@ -232,8 +231,8 @@ export default class SongPlayer { /** * @callback changeListener - * @param {any} old the previous value. - * @param {any} current the the current (new) value. + * @param {*} old the previous value. + * @param {*} current the the current (new) value. */ /**