Skip to content

Commit 55039bb

Browse files
committed
fix list.remove
1 parent c53e9ab commit 55039bb

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

src/js/list.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class List {
107107
list[index].remove();
108108

109109
this.audios.splice(index, 1);
110-
this.lrc.parsed.splice(index, 1);
110+
this.player.lrc && this.player.lrc.remove(index);
111111

112112
if (index === this.index) {
113113
if (this.audios[index]) {
@@ -178,7 +178,7 @@ class List {
178178
this.player.container.classList.remove('aplayer-withlist');
179179
this.player.pause();
180180
this.audios = [];
181-
this.lrc.parsed = [];
181+
this.player.lrc && this.player.lrc.clear();
182182
this.player.audio.src = '';
183183
this.player.template.listOl.innerHTML = '';
184184
this.player.template.pic.style.backgroundImage = '';

src/js/lrc.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,15 @@ class Lrc {
131131
return [];
132132
}
133133
}
134+
135+
remove (index) {
136+
this.parsed.splice(index, 1);
137+
}
138+
139+
clear () {
140+
this.parsed = [];
141+
this.container.innerHTML = '';
142+
}
134143
}
135144

136145
export default Lrc;

src/js/player.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class APlayer {
159159
// audio download error: an error occurs
160160
let skipTime;
161161
this.on('error', () => {
162-
if (this.list.audios.length) {
162+
if (this.list.audios.length > 1) {
163163
this.notice('An audio error has occurred, player will skip forward in 2 seconds.');
164164
skipTime = setTimeout(() => {
165165
this.skipForward();
@@ -168,7 +168,7 @@ class APlayer {
168168
}
169169
}, 2000);
170170
}
171-
else {
171+
else if (this.list.audios.length === 1) {
172172
this.notice('An audio error has occurred.');
173173
}
174174
});

0 commit comments

Comments
 (0)