I'm working on an Android library which is just a simple video player wrapping ExoPlayer. When using an Amazon Fire TV I can navigate my app using the remote (the directional pad switches between elements in my view) and I can control the player (the play/pause button will toggle the playing state and the seek buttons work as intended).... so long as the control bar is visible
After 3 seconds or so the control bar auto-hides, and the remote control becomes non-responsive
Is there an appropriate fix for this, or do I need to manually detect key presses on the remote and show the control bar? I feel like this is the kind of thing Amazon's port of ExoPlayer should have resolved
I extended the PlayerView
class and overrode the dispatchKeyEvent
method to see what was being seen:
public class Test extends PlayerView {
@Override
public boolean dispatchKeyEvent(KeyEvent event)
{
Log.debug("***** KEY EVENT: " + String.valueOf(event.getKeyCode()) + " *********");
return true;
}
}
Doing this and pressing the play button on the remote I noticed:
KeyEvent
with a keyCode
value of 85
was dispatchedI skimmed through the methods available to PlayerView
to see if any were helpful, but nothing seemed worthwhile:
setControllerAutoShow
- determines if control bar is shown when video first startssetControllerHideDuringAds
- determines if the control bar is visible while an ad is playingsetControllerHideOnTouch
- irrelevant on FireTV (no touch events) but hides the control bar if you tap the videosetControllerHideTimeoutMs
- can delay the hiding of the control bar, but otherwise doesn't let me bring it back after it's hiddenshowController
- can forcibly reveal the controller in code, allowing me to pause the video, but I without being able to see keyup events I can't properly call this when a button is pressed on the remote controlUltimately I just want this to behave like the Netflix or Hulu apps -- the control bar goes away after a few seconds of inactivity but if you press the pause button the control bar comes back.
I expanded a bit on your solution to let all the controls work - both the player's and the activity's - since it was not possible to exit the activity anymore and also, on different devices such as phones, it wasn't possible to operate the volume control... this makes everything work, both on the Fire devices and on other devices. I hope it is helpful is someone else stubles into this.
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
// this sends them to the playerView but also to the activity - whoever wants it first
return playerView.dispatchKeyEvent(event) || super.dispatchKeyEvent(event);
}