Headset Hook key event should toggle Chrome media session. |
||||
Issue descriptionChrome Canary (57.0.2974.0) What steps will reproduce the problem? 1. Go to https://beaufortfrancois.github.io/sandbox/media-session/playground.html 2. Play audio to trigger android media notification 3. Dismiss media notification "by error" 4. Press the headset hook key What is the expected result? Audio should be resumed. What happens instead of that? It launches Google Play Music... ;( See my annotated & skimmed adb logs: // Chrome notification is not there... 01-11 09:07:23.523 1083 7683 D MediaSessionService: Sending KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_HEADSETHOOK, scanCode=226, metaState=0, flags=0x8, repeatCount=0, eventTime=548527958, downTime=548527958, deviceId=2, source=0x101 } to the last known pendingIntent PendingIntent{c7ea612: PendingIntentRecord{14746ef com.google.android.music broadcastIntent}} 01-11 09:07:23.525 1083 7683 D MediaSessionService: Sending KeyEvent { action=ACTION_UP, keyCode=KEYCODE_HEADSETHOOK, scanCode=226, metaState=0, flags=0x8, repeatCount=0, eventTime=548527958, downTime=548527958, deviceId=2, source=0x101 } to the last known pendingIntent PendingIntent{c7ea612: PendingIntentRecord{14746ef com.google.android.music broadcastIntent}} 01-11 09:07:23.540 10717 10717 D MusicLifecycle: com.google.android.music.playback.MediaButtonIntentReceiver generated event: Broadcast received with context android.app.ReceiverRestrictedContext@ca0eeb7 and intent Intent { act=android.intent.action.MEDIA_BUTTON flg=0x10000010 cmp=com.google.android.music/.playback.MediaButtonIntentReceiver (has extras) } // Chrome notification is there... 01-11 09:13:44.653 1083 2505 D MediaSessionService: Sending KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_HEADSETHOOK, scanCode=226, metaState=0, flags=0x8, repeatCount=0, eventTime=548909079, downTime=548909079, deviceId=2, source=0x101 } to com.chrome.canary/Chrome Canary (uid=0) 01-11 09:13:44.654 1083 2505 D MediaSessionService: Sending KeyEvent { action=ACTION_UP, keyCode=KEYCODE_HEADSETHOOK, scanCode=226, metaState=0, flags=0x8, repeatCount=0, eventTime=548909079, downTime=548909079, deviceId=2, source=0x101 } to com.chrome.canary/Chrome Canary (uid=0)
,
Jan 11 2017
,
Jan 11 2017
Do you have the Gogole Music notification visible? No. And I've even killed manually GPM (force stop button) As you can see in the adb logs below, it looks like Media Session broadcasts the KeyEvent to the last known pendingIntent (https://developer.android.com/reference/android/app/PendingIntent.html) 01-11 11:37:52.816 1083 1699 D MediaSessionService: Sending KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_HEADSETHOOK, scanCode=226, metaState=0, flags=0x8, repeatCount=0, eventTime=557557238, downTime=557557238, deviceId=2, source=0x101 } to the last known pendingIntent PendingIntent{ca05d87: PendingIntentRecord{14746ef com.google.android.music broadcastIntent}} 01-11 11:37:52.817 1083 1699 D MediaSessionService: Sending KeyEvent { action=ACTION_UP, keyCode=KEYCODE_HEADSETHOOK, scanCode=226, metaState=0, flags=0x8, repeatCount=0, eventTime=557557238, downTime=557557238, deviceId=2, source=0x101 } to the last known pendingIntent PendingIntent{ca05d87: PendingIntentRecord{14746ef com.google.android.music broadcastIntent}} Did you check with another application instead of Chrome? Yup. When I dismiss Spotify notification, and press the headset hook key, Spotify automatically resumes.
,
Jan 11 2017
Yes, I would also suggest won't fix. It might surprise the user if he forget he dismissed the notification before. I think our principle is media session is only active when the notification is shown.
,
Jan 11 2017
I'd argue the use case for using a headset hook key is: - I can't access easily access my phone right now - I just want to listen to what I was listening previously - Press the headset hook key - Resume audio This will always be the last one: it might be Chrome, or Google Play Music, or Spotify, Soundcloud, etc. By the way, this is how I use it when I leave work. I simply want to listen, and I'd be happy if it was the last web app I was using if I'd chose to.
,
Jan 11 2017
Just came up with another reason for not doing this. It is that Chrome may unload some inactive tabs when Android tells the memory pressure is high. So it is unreliable to continue playback after Chrome has been in background for a long time. Having this unreliable feature is not good either.
,
Jan 13 2017
Good call zqzhang@! Does that mean we're restricting this feature to native apps only? Could we do something to make it so that the Android service of Chrome browser wakes up properly the appropriate website (maybe send an event to the Service Worker if there's one)?
,
Jan 13 2017
,
Jan 19 2017
As discussed above, there are no plans to work on this. Maybe the landscape will evolve in a way that will make this feature a good addition to the platform. |
||||
►
Sign in to add a comment |
||||
Comment 1 by mlamouri@chromium.org
, Jan 11 2017Labels: Restrict-View-Google