mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Handle HEADSETHOOK
as 'play' in MediaButtonReceiver.onReceive
Issue: androidx/media#1581 PiperOrigin-RevId: 662515428 (cherry picked from commit c48c051ce29d50411bbc0aaeeae4973354688574)
This commit is contained in:
parent
eebf081528
commit
07e9c659d7
@ -33,6 +33,10 @@
|
||||
action, as
|
||||
[documented](https://developer.android.com/reference/androidx/media3/session/MediaSession#media-key-events-mapping)
|
||||
([#1493](https://github.com/androidx/media/issues/1493)).
|
||||
* Handle `KEYCODE_HEADSETHOOK` as a 'play' command in
|
||||
`MediaButtonReceiver` when deciding whether to ignore it to avoid a
|
||||
`ForegroundServiceDidNotStartInTimeException`
|
||||
([#1581](https://github.com/google/ExoPlayer/issues/1581)).
|
||||
* UI:
|
||||
* Downloads:
|
||||
* OkHttp Extension:
|
||||
|
@ -123,7 +123,8 @@ public class MediaButtonReceiver extends BroadcastReceiver {
|
||||
KeyEvent keyEvent = checkNotNull(intent.getExtras()).getParcelable(Intent.EXTRA_KEY_EVENT);
|
||||
if (keyEvent != null
|
||||
&& keyEvent.getKeyCode() != KeyEvent.KEYCODE_MEDIA_PLAY
|
||||
&& keyEvent.getKeyCode() != KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) {
|
||||
&& keyEvent.getKeyCode() != KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE
|
||||
&& keyEvent.getKeyCode() != KeyEvent.KEYCODE_HEADSETHOOK) {
|
||||
// Starting with Android 8 (API 26), the service must be started immediately in the
|
||||
// foreground when being started. Also starting with Android 8, the system sends media
|
||||
// button intents to this receiver only when the session is released or not active, meaning
|
||||
|
Loading…
x
Reference in New Issue
Block a user