fix: seekTo not working as intended
This commit is contained in:
2 files changed
+9
-6
No files matched your search
@@ -101,7 +101,7 @@ export function VideoPlayer() {
|
||||
toggleIsPlayerMuted,
|
||||
// nextSegmentIndex,
|
||||
// activeSegmentId,
|
||||
// clearActiveSegment,
|
||||
clearActiveSegment,
|
||||
// setActiveSegment,
|
||||
playbackStream,
|
||||
setIsBuffering,
|
||||
@@ -127,7 +127,7 @@ export function VideoPlayer() {
|
||||
toggleIsPlayerFullscreen: state.toggleIsPlayerFullscreen,
|
||||
// nextSegmentIndex: state.nextSegmentIndex,
|
||||
// activeSegmentId: state.activeSegmentId,
|
||||
// clearActiveSegment: state.clearActiveSegment,
|
||||
clearActiveSegment: state.clearActiveSegment,
|
||||
// setActiveSegment: state.setActiveSegment,
|
||||
playbackStream: state.playbackStream,
|
||||
setIsBuffering: state.setIsBuffering,
|
||||
@@ -145,7 +145,7 @@ export function VideoPlayer() {
|
||||
|
||||
const handleReady = async () => {
|
||||
if (api && !isPlayerReady && player.current) {
|
||||
player.current.fastSeek(ticksToSec(userDataLastPlayedPositionTicks ?? 0));
|
||||
player.current.currentTime = ticksToSec(userDataLastPlayedPositionTicks ?? 0);
|
||||
registerPlayerActions({
|
||||
seekTo: (seconds: number) => {
|
||||
const internalPlayer = player.current;
|
||||
@@ -346,6 +346,7 @@ export function VideoPlayer() {
|
||||
|
||||
const handlePlaybackEnded = useCallback(() => {
|
||||
if (queue?.length !== currentQueueItemIndex + 1) {
|
||||
clearActiveSegment(); // Clear active segment when playback ends
|
||||
playItemFromQueue("next", user?.Id, api);
|
||||
} else {
|
||||
handleExitPlayer(); // Exit player if playback has finished and the queue is empty
|
||||
|
||||
@@ -498,10 +498,12 @@ export const usePlaybackStore = create<
|
||||
return 0;
|
||||
},
|
||||
},
|
||||
registerPlayerActions: (actions) =>
|
||||
registerPlayerActions: (actions) => {
|
||||
console.info("Registering player actions:", actions);
|
||||
set({
|
||||
_playerActions: actions,
|
||||
}),
|
||||
});
|
||||
},
|
||||
seekTo: (seconds: number) => {
|
||||
const playerActions = get()._playerActions;
|
||||
playerActions.seekTo(seconds);
|
||||
@@ -576,7 +578,7 @@ export const usePlaybackStore = create<
|
||||
// Update current time to the new seek value
|
||||
set((state) => {
|
||||
state.playerState.isUserSeeking = false;
|
||||
// state.playerState.currentTime = ticks;
|
||||
state.playerState.currentTime = ticks;
|
||||
});
|
||||
},
|
||||
})),
|
||||
|
||||
Reference in new issue
Block a user