List of usage examples for android.media RemoteController sendMediaKeyEvent
public boolean sendMediaKeyEvent(KeyEvent keyEvent) throws IllegalArgumentException
From source file:com.bullmobi.message.services.media.MediaController2KitKat.java
/** * {@inheritDoc}//from w ww . j a v a2 s . c om */ public void sendMediaAction(int action) { int keyCode; switch (action) { case ACTION_PLAY_PAUSE: keyCode = KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE; break; case ACTION_STOP: keyCode = KeyEvent.KEYCODE_MEDIA_STOP; break; case ACTION_SKIP_TO_NEXT: keyCode = KeyEvent.KEYCODE_MEDIA_NEXT; break; case ACTION_SKIP_TO_PREVIOUS: keyCode = KeyEvent.KEYCODE_MEDIA_PREVIOUS; break; default: throw new IllegalArgumentException(); } // TODO We should think about sending these up/down events accurately with touch up/down // on the buttons, but in the near term this will interfere with the long press behavior. RemoteController rc = mService.getRemoteController(); rc.sendMediaKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, keyCode)); rc.sendMediaKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, keyCode)); }
From source file:com.achep.acdisplay.services.media.MediaController2KitKat.java
/** * {@inheritDoc}/*from w w w.j a v a 2s . c o m*/ */ public void sendMediaAction(int action) { if (mService == null) { Log.w(TAG, "Sending a media action on stopped controller."); return; } int keyCode; switch (action) { case ACTION_PLAY_PAUSE: keyCode = KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE; break; case ACTION_STOP: keyCode = KeyEvent.KEYCODE_MEDIA_STOP; break; case ACTION_SKIP_TO_NEXT: keyCode = KeyEvent.KEYCODE_MEDIA_NEXT; break; case ACTION_SKIP_TO_PREVIOUS: keyCode = KeyEvent.KEYCODE_MEDIA_PREVIOUS; break; default: throw new IllegalArgumentException(); } // TODO We should think about sending these up/down events accurately with touch up/down // on the buttons, but in the near term this will interfere with the long press behavior. RemoteController rc = mService.getRemoteController(); rc.sendMediaKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, keyCode)); rc.sendMediaKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, keyCode)); }