mirror of
https://github.com/navidrome/navidrome.git
synced 2026-10-08 02:17:25 +02:00
Merge b36ed26c3c into 52135913d4
This commit is contained in:
commit
2899459439
1 changed files with 15 additions and 0 deletions
|
|
@ -424,6 +424,21 @@ const Player = () => {
|
|||
}
|
||||
}, [isMobilePlayer, audioInstance])
|
||||
|
||||
// The player library maps both the Media Session "play" and "pause" actions
|
||||
// to togglePlay, so an OS "pause" (e.g. when a call starts) resumes paused
|
||||
// music. Re-register them so each only acts in the matching state. This runs
|
||||
// after every player update, as the library re-registers its own handlers.
|
||||
useEffect(() => {
|
||||
if (!audioInstance || !('mediaSession' in navigator)) return
|
||||
if (playerState.current?.isRadio) return
|
||||
navigator.mediaSession.setActionHandler('play', () => {
|
||||
if (audioInstance.paused) audioInstance.togglePlay()
|
||||
})
|
||||
navigator.mediaSession.setActionHandler('pause', () => {
|
||||
if (!audioInstance.paused) audioInstance.togglePlay()
|
||||
})
|
||||
}, [audioInstance, playerState])
|
||||
|
||||
// Report every seek (including programmatic ones the library does not surface
|
||||
// via onAudioSeeked, e.g. restartCurrentOnPrev). Debounce coalesces drag
|
||||
// bursts into one report at the final position.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue