add "stopped" playback state and event handlers

This commit is contained in:
jeffvli
2026-06-29 20:23:46 -07:00
parent a221a84792
commit 37ada07ee2
14 changed files with 147 additions and 40 deletions
+15 -1
View File
@@ -1235,12 +1235,26 @@ export const usePlayerStoreBase = createWithEqualityFn<PlayerState>()(
mediaStop: (options?: { reset?: boolean }) => {
const reset = options?.reset !== false;
set((state) => {
state.player.status = PlayerStatus.PAUSED;
state.player.status = PlayerStatus.STOPPED;
setTimestampStore(0);
if (reset) {
state.player.seekToTimestamp = uniqueSeekToTimestamp(0);
}
});
const currentState = get();
const queue = currentState.getQueue();
const currentIndex = currentState.player.index;
const currentSong = queue.items[currentIndex];
eventEmitter.emit('PLAYER_STOP', {
id: currentSong?._uniqueId,
index:
currentIndex !== undefined && currentIndex >= 0
? currentIndex
: undefined,
reset,
});
},
mediaToggleMute: () => {
set((state) => {