Override playState of mediaSession for Chrome Android

Per Google Developers official doc:

> Note: The browser may consider that the web app is not playing media
> when files are seeking or loading. You can override this behaviour by
> setting navigator.mediaSession.playbackState to "playing" or "paused".
> This comes in handy when you want to make sure your web app UI stays in
> sync with the media notification controls.
This commit is contained in:
An Phan 2017-03-26 11:31:30 +08:00
parent 4618c8744e
commit cc43d5133a
No known key found for this signature in database
GPG key ID: 05536BB4BCDC02A2

View file

@ -93,9 +93,11 @@ export const playback = {
this.pause()
})
navigator.mediaSession.setActionHandler('previoustrack', () => {
navigator.mediaSession.playbackState = 'playing'
this.playPrev()
})
navigator.mediaSession.setActionHandler('nexttrack', () => {
navigator.mediaSession.playbackState = 'playing'
this.playNext()
})
}