1

I've successfully run my application in Chrome with ARC Welder. I want to use Play/Pause buttons on my MacBook inside my Application.

My application is responding the media buttons normally in Android like below. It is working on Google TVs and Android TVs. But not working on Chrome ARC.

I've also responding to space and enter buttons and they are working on Chrome ARC perfectly.

Here is the code I am using in my Activity:

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    switch (keyCode) {
        case KeyEvent.KEYCODE_MEDIA_PLAY:
        case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
        case KeyEvent.KEYCODE_MEDIA_PAUSE:
        case KeyEvent.KEYCODE_SPACE:
        case KeyEvent.KEYCODE_ENTER:
        case KeyEvent.KEYCODE_NUMPAD_ENTER:
        case KeyEvent.KEYCODE_DPAD_CENTER:
            playPause();
            return true;
        case KeyEvent.KEYCODE_MEDIA_STOP:
            sendOrderedBroadcast(BaseNotificationService.STOP_INTENT, null);
            return true;
        default:
            return super.onKeyUp(keyCode, event);
    }
}

How do you think it can be done? Is it possible? Can there be a workaround to support Play/Pause buttons?

tasomaniac
  • 10,234
  • 6
  • 52
  • 84
  • On a whim, add some logging to your `default`, to see if there is anything sent to `onKeyUp()` for those buttons, albeit perhaps oddly mapped by ARC. – CommonsWare Apr 16 '15 at 14:36
  • Already did it. It doesn't output anything on media button on key press. I am on chrome 42 on Yosemite – tasomaniac Apr 16 '15 at 14:38

1 Answers1

5

ARC currently lacks a complete mapping to translate all keycodes we get through the Chrome PPAPI into their Android equivalent versions.

There isn't really a work around -- the keyboard event just won't go through since there is no translation for it.

Since I tracked down some specifics while looking into it, I went ahead and filed this bug to track it. Feel free to star it.

Lloyd Pique
  • 916
  • 5
  • 5