fix(Remote playback): kludge to scrub after stream move
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
|
||||
import { type UnlistenFn } from "@tauri-apps/api/event";
|
||||
import { commands, events, type PlayerStatusEvent, type SleepTimerMode } from "$lib/api/bindings";
|
||||
import { player, playbackPosition } from "$lib/stores/player";
|
||||
import { player, playbackPosition, currentMedia } from "$lib/stores/player";
|
||||
import { queue, currentQueueItem } from "$lib/stores/queue";
|
||||
import { playbackMode } from "$lib/stores/playbackMode";
|
||||
import { sleepTimer } from "$lib/stores/sleepTimer";
|
||||
@@ -163,9 +163,16 @@ async function handleStateChanged(state: string, _mediaId: string | null): Promi
|
||||
}
|
||||
|
||||
if (state === "playing" && currentItem) {
|
||||
// Use 0 for position/duration - will be updated by position_update events
|
||||
// Preserve the current position when the same track is already loaded
|
||||
// (e.g. resuming from pause, or a spurious PlaybackRestart). Only reset
|
||||
// to 0 when switching to a different track. position_update events keep
|
||||
// it fresh either way, but resetting unconditionally caused the time to
|
||||
// flash to 0:00 on pause/resume.
|
||||
const previous = get(currentMedia);
|
||||
const isSameTrack = previous?.id === currentItem.id;
|
||||
const startPosition = isSameTrack ? get(playbackPosition) : 0;
|
||||
const initialDuration = currentItem.runTimeTicks ? currentItem.runTimeTicks / 10000000 : 0;
|
||||
player.setPlaying(currentItem, 0, initialDuration);
|
||||
player.setPlaying(currentItem, startPosition, initialDuration);
|
||||
|
||||
// Trigger preloading of upcoming tracks in the background
|
||||
preloadUpcomingTracks().catch((e) => {
|
||||
|
||||
Reference in New Issue
Block a user