Skip to content
Merged
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
17 changes: 1 addition & 16 deletions src/ui/PodcastView/EpisodePlayer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,7 @@

let srcPromise: Promise<string> = getSrc($currentEpisode);

// #region Keep player time and currentTime in sync
// Simply binding currentTime to the audio element will result in resets.
// Hence the following solution.
let playerTime: number = 0;

onMount(() => {
const unsub = currentTime.subscribe((ct) => {
playerTime = ct;
});

// This only happens when the player is open and the user downloads the episode via the context menu.
// So we want to update the source of the audio element to local file / online stream.
const unsubDownloadedSource = downloadedEpisodes.subscribe(_ => {
Expand All @@ -139,18 +130,12 @@
});

return () => {
unsub();
unsubDownloadedSource();
unsubCurrentEpisode();
unsubVolume();
};
});

$: {
currentTime.set(playerTime);
}
// #endregion

onDestroy(() => {
playedEpisodes.setEpisodeTime($currentEpisode, $currentTime, $duration, ($currentTime === $duration));
isPaused.set(true);
Expand Down Expand Up @@ -234,7 +219,7 @@
<audio
src={src}
bind:duration={$duration}
bind:currentTime={playerTime}
bind:currentTime={$currentTime}
bind:paused={$isPaused}
bind:playbackRate={offBinding._playbackRate}
bind:volume={playerVolume}
Expand Down