Skip to content

Commit

Permalink
Fix lyric and add error handler
Browse files Browse the repository at this point in the history
  • Loading branch information
YUCLing committed Feb 28, 2021
1 parent 2d9cf07 commit d0db209
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/typescript/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ const volumeHandlers = {
(<HTMLSpanElement>el.querySelector(".penguin-player__player--progress-current")).textContent = formatTime(this.currentTime);
(<HTMLDivElement>el.querySelector(".penguin-player__player--progress-inner")).style.width = (this.currentTime / this.duration * 100) + "%";
});
audio.addEventListener("error", () => {print("Cannot play " + songs[currentSong].name);next();})
// Volume setup
setVolume(1);
try {
Expand Down Expand Up @@ -421,6 +422,8 @@ function play(id?: number) {
}
(<HTMLAudioElement>el.querySelector(".penguin-player__audio")).pause();
currentSong = id;
lrcStartPos = 0;
tLrcStartPos = 0;
lyric = undefined;
tLrc = undefined;
let song = songs[currentSong];
Expand Down Expand Up @@ -503,7 +506,6 @@ function play(id?: number) {
if (result.data.lyric) {
lyric = result.data.lyric.lrc;
tLrc = result.data.lyric.tlrc;
requestAnimationFrame(lyricUpdater);
} else {
print(`No lyric for ${song.name}`);
}
Expand Down

0 comments on commit d0db209

Please sign in to comment.