fix list.remove

This commit is contained in:
DIYgod
2018-03-29 23:07:12 +08:00
parent c53e9abd1c
commit 55039bbc3b
3 changed files with 13 additions and 4 deletions
+2 -2
View File
@@ -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 = '';
+9
View File
@@ -131,6 +131,15 @@ class Lrc {
return [];
}
}
remove (index) {
this.parsed.splice(index, 1);
}
clear () {
this.parsed = [];
this.container.innerHTML = '';
}
}
export default Lrc;
+2 -2
View File
@@ -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.');
}
});