WIP: Audio context fixes - single context, playback switching, playhead sync improvements
This commit is contained in:
@@ -6,12 +6,15 @@ interface PlayerState {
|
||||
duration: number;
|
||||
currentSongId: string | null;
|
||||
currentBandId: string | null;
|
||||
currentPlayingSongId: string | null; // Track which song is actively playing
|
||||
currentPlayingBandId: string | null; // Track which band's song is actively playing
|
||||
setPlaying: (isPlaying: boolean) => void;
|
||||
setCurrentTime: (currentTime: number) => void;
|
||||
setDuration: (duration: number) => void;
|
||||
setCurrentSong: (songId: string | null, bandId: string | null) => void;
|
||||
setCurrentPlayingSong: (songId: string | null, bandId: string | null) => void;
|
||||
reset: () => void;
|
||||
batchUpdate: (updates: Partial<Omit<PlayerState, 'setPlaying' | 'setCurrentTime' | 'setDuration' | 'setCurrentSong' | 'reset' | 'batchUpdate'>>) => void;
|
||||
batchUpdate: (updates: Partial<Omit<PlayerState, 'setPlaying' | 'setCurrentTime' | 'setDuration' | 'setCurrentSong' | 'setCurrentPlayingSong' | 'reset' | 'batchUpdate'>>) => void;
|
||||
}
|
||||
|
||||
export const usePlayerStore = create<PlayerState>()((set) => ({
|
||||
@@ -20,16 +23,21 @@ export const usePlayerStore = create<PlayerState>()((set) => ({
|
||||
duration: 0,
|
||||
currentSongId: null,
|
||||
currentBandId: null,
|
||||
currentPlayingSongId: null,
|
||||
currentPlayingBandId: null,
|
||||
setPlaying: (isPlaying) => set({ isPlaying }),
|
||||
setCurrentTime: (currentTime) => set({ currentTime }),
|
||||
setDuration: (duration) => set({ duration }),
|
||||
setCurrentSong: (songId, bandId) => set({ currentSongId: songId, currentBandId: bandId }),
|
||||
setCurrentPlayingSong: (songId, bandId) => set({ currentPlayingSongId: songId, currentPlayingBandId: bandId }),
|
||||
batchUpdate: (updates) => set(updates),
|
||||
reset: () => set({
|
||||
isPlaying: false,
|
||||
currentTime: 0,
|
||||
duration: 0,
|
||||
currentSongId: null,
|
||||
currentBandId: null
|
||||
currentBandId: null,
|
||||
currentPlayingSongId: null,
|
||||
currentPlayingBandId: null
|
||||
})
|
||||
}));
|
||||
Reference in New Issue
Block a user