Skip to content

Commit

Permalink
refactor(player): extract nextFromPlaylist function #23
Browse files Browse the repository at this point in the history
  • Loading branch information
rudywaltz committed Sep 25, 2019
1 parent 678f1c4 commit b5a2f9b
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/components/Player.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,27 @@
return;
}
$song = $playlist.shift();
$playlist = $playlist; //TODO: nicer solution
currentSound = createCurrentSong();
nextFromPlaylist();
}
const nextSong = () => {
currentSound.unload();
if (!$playlist.length) {
clearPollingSong = true;
resetSongStatus();
return;
}
$song = $playlist.shift();
$playlist = $playlist; //TODO: nicer solution
currentSound = createCurrentSong();
nextFromPlaylist();
}
const nextFromPlaylist = () => {
$song = $playlist.shift();
$playlist = $playlist; //TODO: nicer solution
currentSound = createCurrentSong();
}
const toggleSound = () => playing ? pauseSound() : playSound();
const playSound = () => {
Expand All @@ -102,7 +106,6 @@
clearPollingSong = false;
const pollingSongData = setInterval(() => {
console.log('pollypirot');
if (!playing) {
time = 0;
clearInterval(pollingSongData);
Expand Down

0 comments on commit b5a2f9b

Please sign in to comment.