mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-09 20:29:36 +02:00
support offset for player skip
This commit is contained in:
@@ -41,8 +41,8 @@ interface Actions {
|
|||||||
mediaPlay: (id?: string) => void;
|
mediaPlay: (id?: string) => void;
|
||||||
mediaPrevious: () => void;
|
mediaPrevious: () => void;
|
||||||
mediaSeekToTimestamp: (timestamp: number) => void;
|
mediaSeekToTimestamp: (timestamp: number) => void;
|
||||||
mediaSkipBackward: () => void;
|
mediaSkipBackward: (offset?: number) => void;
|
||||||
mediaSkipForward: () => void;
|
mediaSkipForward: (offset?: number) => void;
|
||||||
mediaStop: () => void;
|
mediaStop: () => void;
|
||||||
mediaToggleMute: () => void;
|
mediaToggleMute: () => void;
|
||||||
mediaTogglePlayPause: () => void;
|
mediaTogglePlayPause: () => void;
|
||||||
@@ -603,24 +603,25 @@ export const usePlayerStoreBase = create<PlayerState>()(
|
|||||||
state.player.seekToTimestamp = uniqueSeekToTimestamp(timestamp);
|
state.player.seekToTimestamp = uniqueSeekToTimestamp(timestamp);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
mediaSkipBackward: () => {
|
mediaSkipBackward: (offset?: number) => {
|
||||||
set((state) => {
|
set((state) => {
|
||||||
const timeToSkip =
|
const offsetFromSettings =
|
||||||
useSettingsStore.getState().general.skipButtons.skipBackwardSeconds ||
|
useSettingsStore.getState().general.skipButtons.skipBackwardSeconds;
|
||||||
5;
|
const timeToSkip = offset ?? offsetFromSettings ?? 5;
|
||||||
const newTimestamp = Math.max(0, state.player.timestamp - timeToSkip);
|
const newTimestamp = Math.max(0, state.player.timestamp - timeToSkip);
|
||||||
|
|
||||||
state.player.seekToTimestamp = uniqueSeekToTimestamp(newTimestamp);
|
state.player.seekToTimestamp = uniqueSeekToTimestamp(newTimestamp);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
mediaSkipForward: () => {
|
mediaSkipForward: (offset?: number) => {
|
||||||
set((state) => {
|
set((state) => {
|
||||||
const queue = state.getQueue();
|
const queue = state.getQueue();
|
||||||
const index = state.player.index;
|
const index = state.player.index;
|
||||||
const currentTrack = queue.items[index];
|
const currentTrack = queue.items[index];
|
||||||
const duration = currentTrack?.duration;
|
const duration = currentTrack?.duration;
|
||||||
const timeToSkip =
|
const offsetFromSettings =
|
||||||
useSettingsStore.getState().general.skipButtons.skipForwardSeconds || 5;
|
useSettingsStore.getState().general.skipButtons.skipForwardSeconds;
|
||||||
|
const timeToSkip = offset ?? offsetFromSettings ?? 5;
|
||||||
|
|
||||||
if (!duration) {
|
if (!duration) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user