diff --git a/src/js/list.js b/src/js/list.js index 9c831ff..c8aeaf5 100644 --- a/src/js/list.js +++ b/src/js/list.js @@ -107,7 +107,7 @@ class List { list[index].remove(); this.audios.splice(index, 1); - this.lrc.parsed.splice(index, 1); + this.player.lrc && this.player.lrc.remove(index); if (index === this.index) { if (this.audios[index]) { @@ -178,7 +178,7 @@ class List { this.player.container.classList.remove('aplayer-withlist'); this.player.pause(); this.audios = []; - this.lrc.parsed = []; + this.player.lrc && this.player.lrc.clear(); this.player.audio.src = ''; this.player.template.listOl.innerHTML = ''; this.player.template.pic.style.backgroundImage = ''; diff --git a/src/js/lrc.js b/src/js/lrc.js index 38326fc..39cabb8 100644 --- a/src/js/lrc.js +++ b/src/js/lrc.js @@ -131,6 +131,15 @@ class Lrc { return []; } } + + remove (index) { + this.parsed.splice(index, 1); + } + + clear () { + this.parsed = []; + this.container.innerHTML = ''; + } } export default Lrc; \ No newline at end of file diff --git a/src/js/player.js b/src/js/player.js index 088a011..d9a2689 100644 --- a/src/js/player.js +++ b/src/js/player.js @@ -159,7 +159,7 @@ class APlayer { // audio download error: an error occurs let skipTime; this.on('error', () => { - if (this.list.audios.length) { + if (this.list.audios.length > 1) { this.notice('An audio error has occurred, player will skip forward in 2 seconds.'); skipTime = setTimeout(() => { this.skipForward(); @@ -168,7 +168,7 @@ class APlayer { } }, 2000); } - else { + else if (this.list.audios.length === 1) { this.notice('An audio error has occurred.'); } });