mirror of
https://github.com/Jellify-Music/App.git
synced 2026-01-15 23:40:25 -06:00
Add more query usage
This commit is contained in:
@@ -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()} />;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user