Skip to content

Commit 702bc0f

Browse files
committed
feat: если нет песен - перестать проигрывать
1 parent 0eb9751 commit 702bc0f

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/structures/list/examples/music-player/music-player.vue

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,27 @@ const updateProgress = () => {
4141
}
4242
4343
const removeCurrentSong = () => {
44-
if (!currentSong.value) return
44+
if (!currentSong.value) return;
4545
46-
const currentSongTitle = currentSong.value.value.title
47-
playlist.value.removeCurrent()
48-
songs.value = songs.value.filter((song) => song.title !== currentSongTitle)
46+
const currentSongTitle = currentSong.value.value.title;
47+
playlist.value.removeCurrent();
48+
songs.value = songs.value.filter((song) => song.title !== currentSongTitle);
4949
5050
if (playlist.value.current) {
51-
currentSong.value = playlist.value.current
51+
currentSong.value = playlist.value.current;
5252
if (audioPlayer.value) {
53-
audioPlayer.value.src = currentSong.value.value.src
53+
audioPlayer.value.src = currentSong.value.value.src;
5454
if (isPlaying.value) {
55-
audioPlayer.value.play()
55+
audioPlayer.value.play();
5656
}
5757
}
5858
} else {
59-
currentSong.value = null
59+
currentSong.value = null;
60+
if (audioPlayer.value) {
61+
audioPlayer.value.pause();
62+
audioPlayer.value.src = '';
63+
isPlaying.value = false;
64+
}
6065
}
6166
}
6267

0 commit comments

Comments
 (0)