Skip to content

Commit

Permalink
Improve handling keys
Browse files Browse the repository at this point in the history
  • Loading branch information
moneytoo committed Jul 25, 2022
1 parent f42afb1 commit d840b7d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions app/src/main/java/com/brouken/player/PlayerActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -803,12 +803,23 @@ public boolean onKeyDown(int keyCode, KeyEvent event) {
case KeyEvent.KEYCODE_MEDIA_PLAY:
case KeyEvent.KEYCODE_MEDIA_PAUSE:
case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
break;
case KeyEvent.KEYCODE_BUTTON_SELECT:
if (player == null)
break;
if (keyCode == KeyEvent.KEYCODE_MEDIA_PAUSE) {
player.pause();
} else if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY) {
player.play();
} else if (player.isPlaying()) {
player.pause();
} else {
player.play();
}
return true;
case KeyEvent.KEYCODE_VOLUME_UP:
case KeyEvent.KEYCODE_VOLUME_DOWN:
Utils.adjustVolume(this, mAudioManager, playerView, keyCode == KeyEvent.KEYCODE_VOLUME_UP, event.getRepeatCount() == 0, true);
return true;
case KeyEvent.KEYCODE_BUTTON_SELECT:
case KeyEvent.KEYCODE_BUTTON_START:
case KeyEvent.KEYCODE_BUTTON_A:
case KeyEvent.KEYCODE_ENTER:
Expand Down

0 comments on commit d840b7d

Please sign in to comment.