Fix:Android media play/pause event #429 #427

This commit is contained in:
advplyr 2023-02-04 11:13:19 -06:00
parent 944aa5de66
commit 55b7f05685

View file

@ -138,19 +138,21 @@ class MediaSessionCallback(var playerNotificationService:PlayerNotificationServi
Log.d(tag, "handleCallMediaButton keyEvent = $keyEvent | action ${keyEvent?.action}")
if (keyEvent?.action == KeyEvent.ACTION_DOWN) {
Log.d(tag, "handleCallMediaButton: key action_down for ${keyEvent.keyCode}")
when (keyEvent.keyCode) {
KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE -> {
Log.d(tag, "handleCallMediaButton: Media Play/Pause")
if (playerNotificationService.mPlayer.isPlaying) {
playerNotificationService.pause()
} else {
playerNotificationService.play()
}
}
}
}
// TODO: Widget was only sending this event on key down
// but this cannot be defined in both key down and key up
// if (keyEvent?.action == KeyEvent.ACTION_DOWN) {
// Log.d(tag, "handleCallMediaButton: key action_down for ${keyEvent.keyCode}")
// when (keyEvent.keyCode) {
// KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE -> {
// Log.d(tag, "handleCallMediaButton: Media Play/Pause")
// if (playerNotificationService.mPlayer.isPlaying) {
// playerNotificationService.pause()
// } else {
// playerNotificationService.play()
// }
// }
// }
// }
if (keyEvent?.action == KeyEvent.ACTION_UP) {
Log.d(tag, "handleCallMediaButton: key action_up for ${keyEvent.keyCode}")