示例#1
0
  private void handleAudioControlEvent(Intent intent) {
    KeyEvent event = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);

    if (event == null) {
      return;
    }

    if (event.getAction() != KeyEvent.ACTION_DOWN) {
      return;
    }

    switch (event.getKeyCode()) {
      case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
        BusProvider.getBus().post(new AudioControlPlayPauseEvent());
        break;

      case KeyEvent.KEYCODE_MEDIA_PLAY:
        BusProvider.getBus().post(new AudioControlPlayEvent());
        break;

      case KeyEvent.KEYCODE_MEDIA_PAUSE:
        BusProvider.getBus().post(new AudioControlPauseEvent());
        break;

      case KeyEvent.KEYCODE_MEDIA_NEXT:
        BusProvider.getBus().post(new AudioControlNextEvent());
        break;

      case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
        BusProvider.getBus().post(new AudioControlPreviousEvent());
        break;

      default:
        break;
    }
  }
示例#2
0
 private void handleAudioChangeEvent() {
   BusProvider.getBus().post(new AudioControlPauseEvent());
 }