I am developing a custom UI on top of ExoPlayer, and I noticed that the controls (PlaybackControlView
) hide when I touch the screen, not when I click.
I wanted to change to a click and checked how I can change the event listener, but so far could not find an easy solution. I checked the source SimpleExoPlayerView.java
and I noticed that it actually is hardcoded:
@Override
public boolean onTouchEvent(MotionEvent ev) {
if (!useController || player == null || ev.getActionMasked() != MotionEvent.ACTION_DOWN) {
return false;
}
if (controller.isVisible()) {
controller.hide();
} else {
maybeShowController(true);
}
return true;
}
So far I could think of two solutions. One is to change the ExoPlayer's source code, but I do not like it since I will have to make modifications every time I update the ExoPlayer.
The second solution I could think of is simply to try to handle it myself, for example, to add my own listeners, and show and hide the controls myself. I have not tried this yet, but it seems possible.
Is there another better solution, like overriding the listeners, etc?
Update: I am using custom UI by inflating exo_playback_control_view.xml