feat(playback): keep transfer position and sync devices
Continuous Integration / build_web (push) Failing after 0s
Continuous Integration / build (macos-latest) (push) Skipped
Continuous Integration / build (ubuntu-22.04) (push) Skipped
Continuous Integration / build (windows-11-arm) (push) Skipped
Continuous Integration / build (windows-latest) (push) Skipped
Continuous Integration / nightly_release (push) Skipped

Transfers now start the current item first in the queue and send a corrective Seek for clients that ignore StartPositionTicks. Adds a Sync playback mode that keeps other sessions playing the same item aligned with the active device.
This commit is contained in:
1xDed committed 2026-11-28 00:31:03 +03:00
1 parent df392eb647
commit 4bdd0139bf
8 files changed
+461 -19

No files matched your search

@@ -20,6 +20,7 @@ import {
changeSubtitleTrack,
usePlaybackStore,
} from "@/utils/store/playback";
import useSyncPlayback from "@/utils/store/syncPlayback";
type VideoPlayerSettingsMenuProps = {
settingsMenuRef: HTMLButtonElement | null;
@@ -41,15 +42,31 @@ const VideoPlayerSettingsMenu = ({
setIsBuffering,
showStatsForNerds,
toggleShowStatsForNerds,
itemId,
} = usePlaybackStore(
useShallow((state) => ({
mediaSource: state.mediaSource,
setIsBuffering: state.setIsBuffering,
showStatsForNerds: state.playerState.showStatsForNerds,
toggleShowStatsForNerds: state.toggleShowStatsForNerds,
itemId: state.metadata.item?.Id,
})),
);
const syncEnabled = useSyncPlayback((state) => state.enabled);
const syncMaster = useSyncPlayback((state) => state.master);
const startSync = useSyncPlayback((state) => state.start);
const stopSync = useSyncPlayback((state) => state.stop);
const syncForThisVideo =
syncEnabled && syncMaster?.sessionId === null && Boolean(itemId);
const toggleSync = () => {
if (syncForThisVideo) {
stopSync();
return;
}
if (itemId) startSync({ itemId, sessionId: null });
};
const [subtitleIsChanging, startSubtitleChange] = useTransition();
const handleSubtitleChange: ChangeEventHandler<
HTMLInputElement | HTMLTextAreaElement
@@ -156,6 +173,21 @@ const VideoPlayerSettingsMenu = ({
</Typography>
<Switch checked={showStatsForNerds} />
</MenuItem>
<MenuItem onClick={toggleSync} disabled={!itemId}>
<Typography
sx={{
flexGrow: 1,
}}
>
Sync playback
</Typography>
<Switch
checked={syncForThisVideo}
disabled={!itemId}
onClick={(event) => event.stopPropagation()}
onChange={toggleSync}
/>
</MenuItem>
</MenuList>
</Popover>
);