Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion MyMusicClientSveltePwa/src/lib/pages/Playlist.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { writable } from "svelte/store";
import { onDestroy, onMount, setContext } from "svelte";
import { getCachedPlaylistSongs } from "../scripts/storageService";
import { playOrPauseSong, setPlaylists } from "../scripts/playbackService";
import { playOrPauseSong, setPlaylists, updateCurrentPlaylist } from "../scripts/playbackService";
import SongComponent from "../components/SongComponent.svelte";

const updateIntervalTimeOut = 1000; // Update every second
Expand All @@ -19,6 +19,7 @@

intervalId = setInterval(() => {
songs.set(getCachedPlaylistSongs(playlistId));
updateCurrentPlaylist(playlistId);
}, updateIntervalTimeOut);
});

Expand Down
11 changes: 11 additions & 0 deletions MyMusicClientSveltePwa/src/lib/scripts/playbackService.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,17 @@ export function setCurrentTime(seconds) {
audioElement.currentTime = seconds;
}

export function updateCurrentPlaylist(playlistId){
if (currentPlaylistId === playlistId) {
// update current playlist
originalPlaylistSongs = getCachedPlaylistSongs(playlistId);

// Todo get the difference between originalPlaylistSongs and playlistSongs
// and update playlistSongs accordingly if shuffle is enabled
return; // Already set to this playlist
}
}

export function setPlaylists(playlistId) {
if (currentPlaylistId === playlistId) {
// update current playlist
Expand Down