Skip to content

Commit

Permalink
fix list.remove
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed Mar 29, 2018
1 parent c53e9ab commit 55039bb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/js/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]) {
Expand Down Expand Up @@ -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 = '';
Expand Down
9 changes: 9 additions & 0 deletions src/js/lrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@ class Lrc {
return [];
}
}

remove (index) {
this.parsed.splice(index, 1);
}

clear () {
this.parsed = [];
this.container.innerHTML = '';
}
}

export default Lrc;
4 changes: 2 additions & 2 deletions src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -168,7 +168,7 @@ class APlayer {
}
}, 2000);
}
else {
else if (this.list.audios.length === 1) {
this.notice('An audio error has occurred.');
}
});
Expand Down

0 comments on commit 55039bb

Please sign in to comment.