Add more query usage

This commit is contained in:
Violet Caulfield
2025-01-06 16:11:05 -06:00
parent 94e497ff75
commit 075ea10bcb
3 changed files with 6 additions and 13 deletions

View File

@@ -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 = <Icon name="pause" large onPress={() => pause()} />;

View File

@@ -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,

View File

@@ -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