Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save michael-riha/78b1ccc91801136027dd77d2510fd55b to your computer and use it in GitHub Desktop.
Save michael-riha/78b1ccc91801136027dd77d2510fd55b to your computer and use it in GitHub Desktop.
In the handleUserInput method, we pass the code of the key pushed by D-Pad or gamepad - https://github.com/bitmovin/bitmovin-player-android-samples/
//https://github.com/bitmovin/bitmovin-player-android-samples/blob/5f0719f954e4ce8faee1bb290bed715a7ae1b935/BasicPlaybackTV/src/main/java/com/bitmovin/samples/tv/playback/basic/MainActivity.java#L134-L167
private boolean handleUserInput(int keycode)
{
Log.d(TAG, "Keycode " + keycode);
switch (keycode)
{
case KeyEvent.KEYCODE_DPAD_CENTER:
case KeyEvent.KEYCODE_ENTER:
case KeyEvent.KEYCODE_NUMPAD_ENTER:
case KeyEvent.KEYCODE_SPACE:
case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
this.togglePlay();
return true;
case KeyEvent.KEYCODE_MEDIA_PLAY:
this.bitmovinPlayer.play();
return true;
case KeyEvent.KEYCODE_MEDIA_PAUSE:
this.bitmovinPlayer.pause();
return true;
case KeyEvent.KEYCODE_MEDIA_STOP:
this.stopPlayback();
return true;
case KeyEvent.KEYCODE_DPAD_RIGHT:
case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
this.seekForward();
break;
case KeyEvent.KEYCODE_DPAD_LEFT:
case KeyEvent.KEYCODE_MEDIA_REWIND:
this.seekBackward();
break;
default:
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment