New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 680026 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: Jan 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android , Chrome
Pri: 3
Type: Bug



Sign in to add a comment

Headset Hook key event should toggle Chrome media session.

Project Member Reported by fbeaufort@chromium.org, Jan 11 2017

Issue description

Chrome 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)

 
Cc: zqzh...@chromium.org
Labels: Restrict-View-Google
I would tend to consider this a WontFix but I want to check what you are doing exactly before. Do you have the Gogole Music notification visible? We shouldn't handle the headset button when we don't have an active [Android] MediaSession and we de-activate it when the notification is dismissed because we take this as a hint from the user that they don't want to interact with the notification. If Google Music doesn't have a visible notification, I would consider this a bug on their side. Did you check with another application instead of Chrome?
Cc: mlamouri@chromium.org
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.



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.
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.
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.
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)?
Labels: -Restrict-View-Google
Status: WontFix (was: Unconfirmed)
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