mirror of
https://github.com/austinried/subtracks.git
synced 2026-02-10 15:02:42 +01:00
check if we paused on duck before playing again (#51)
prevents music playing after an alarm or call ends if it wasn't paused by that alarm/call in the first place
This commit is contained in:
@@ -34,6 +34,12 @@ const rebuildQueue = () => {
|
||||
})
|
||||
}
|
||||
|
||||
const setDuckPaused = (duckPaused: boolean) => {
|
||||
unstable_batchedUpdates(() => {
|
||||
useStore.getState().setDuckPaused(duckPaused)
|
||||
})
|
||||
}
|
||||
|
||||
let serviceCreated = false
|
||||
|
||||
const createService = async () => {
|
||||
@@ -81,9 +87,14 @@ const createService = async () => {
|
||||
}
|
||||
|
||||
if (data.paused) {
|
||||
trackPlayerCommands.enqueue(TrackPlayer.pause)
|
||||
} else {
|
||||
let state = useStore.getState().playerState
|
||||
if (state === State.Playing || state === State.Buffering || state === State.Connecting) {
|
||||
trackPlayerCommands.enqueue(TrackPlayer.pause)
|
||||
setDuckPaused(true)
|
||||
}
|
||||
} else if (useStore.getState().duckPaused) {
|
||||
trackPlayerCommands.enqueue(TrackPlayer.play)
|
||||
setDuckPaused(false)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user