From 075ea10bcb8a8a1e969833bd40b97d50e5c8caea Mon Sep 17 00:00:00 2001 From: Violet Caulfield Date: Mon, 6 Jan 2025 16:11:05 -0600 Subject: [PATCH] Add more query usage --- components/Player/helpers/buttons.tsx | 2 -- player/handlers.ts | 2 ++ player/provider.tsx | 15 ++++----------- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/components/Player/helpers/buttons.tsx b/components/Player/helpers/buttons.tsx index 9c921ad6..54b99d40 100644 --- a/components/Player/helpers/buttons.tsx +++ b/components/Player/helpers/buttons.tsx @@ -7,8 +7,6 @@ export function playPauseButton(playbackState: State | undefined, play: Function let button : React.JSX.Element; - console.debug(`Playback State: ${playbackState}`) - switch (playbackState) { case (State.Playing) : { button = pause()} />; diff --git a/player/handlers.ts b/player/handlers.ts index 71290d9d..313e2c30 100644 --- a/player/handlers.ts +++ b/player/handlers.ts @@ -11,6 +11,8 @@ export const usePlaybackStopped = (sessionId: string, playStateApi: PlaystateApi const activeTrack : JellifyTrack = queryKey[2] as JellifyTrack; const playStateApi : PlaystateApi = queryKey[3] as PlaystateApi; + console.debug("Stopping playback for session") + return await playStateApi.reportPlaybackStopped({ playbackStopInfo: { SessionId: sessionId, diff --git a/player/provider.tsx b/player/provider.tsx index 112813f1..3b77a3b1 100644 --- a/player/provider.tsx +++ b/player/provider.tsx @@ -66,12 +66,8 @@ const PlayerContextInitializer = () => { TrackPlayer.pause(); const activeTrack = await TrackPlayer.getActiveTrack() as JellifyTrack; - playStateApi.reportPlaybackStopped({ - playbackStopInfo: { - SessionId: sessionId, - ItemId: activeTrack.ItemId - } - }) + + usePlaybackStopped(sessionId, playStateApi, activeTrack) } const resetQueue = async (hideMiniplayer?: boolean | undefined) => { @@ -100,19 +96,16 @@ const PlayerContextInitializer = () => { useTrackPlayerEvents([ Event.PlaybackActiveTrackChanged, ], async (event) => { - - console.debug(`TrackPlayer Event received: ${event}`); - switch (event.type) { - case (Event.PlaybackActiveTrackChanged) : { + + console.debug("Active track changed"); // Scrobble previously played track if (nowPlaying) { usePlaybackStopped(sessionId, playStateApi, nowPlaying) } - console.debug("Active track changed"); // Sleep before capturing the active track in case we are // skipping to an initial queue index