private void handleKeyEvent(KeyEvent event) {
    if (event.getAction() != KeyEvent.ACTION_DOWN || event.getRepeatCount() > 0) {
      return;
    }

    switch (event.getKeyCode()) {
      case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
      case KeyEvent.KEYCODE_HEADSETHOOK:
        downloadService.togglePlayPause();
        break;
      case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
        downloadService.previous();
        break;
      case KeyEvent.KEYCODE_MEDIA_NEXT:
        if (downloadService.getCurrentPlayingIndex() < downloadService.size() - 1) {
          downloadService.next();
        }
        break;
      case KeyEvent.KEYCODE_MEDIA_STOP:
        downloadService.reset();
        break;
      case KeyEvent.KEYCODE_MEDIA_PLAY:
        downloadService.play();
        break;
      case KeyEvent.KEYCODE_MEDIA_PAUSE:
        downloadService.pause();
        break;
      default:
        break;
    }
  }