Exoplayer hide PlaybackControlView onClick (not onTouch)

exoplayer hide next button
exoplayer playbackcontrolview example
exoplayer hide controls
exoplayer next button listener
exoplayer hide buttons
hide player control exoplayer
android exoplayer hide seekbar
exoplayer always hide controls

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


By looking at this answer you can see that an OnTouchListener#onTouch is called BEFORE the View#onTouchEvent so you can set an OnTouchListener to the view, consume the MotionEvent and it will not be passed onto the onTouchEvent method.

For example, using this code only "onTouch: LISTENER!!!" is logged when touching the view, and not "onTouchEvent: onTouchEvent!!!":

EDIT - to add your request for a click event handling I added the use of GestureDetector, using this answer - so now upon click "onSingleTapUp: TAP DETECTED" is logged as well.

public class TouchingView extends View {

    private final static String TAG="TouchingView";

    private OnTouchListener touchListener;
    private GestureDetector gestureDetector;

    public TouchingView(Context context) {
        super(context);
        touchListener = new TouchListener();
        gestureDetector = new GestureDetector(getContext(), 
                         (GestureDetector.OnGestureListener) touchListener);
        setOnTouchListener(touchListener);
    }

    public TouchingView(Context context, AttributeSet attrs) {
        super(context, attrs);
        touchListener = new TouchListener();
        gestureDetector = new GestureDetector(getContext(), 
                         (GestureDetector.OnGestureListener) touchListener);
        setOnTouchListener(touchListener);
    }

    public TouchingView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        touchListener = new TouchListener();
        gestureDetector = new GestureDetector(getContext(), 
                         (GestureDetector.OnGestureListener) touchListener);
        setOnTouchListener(touchListener);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        Log.d(TAG, "onTouchEvent: onTouchEvent!!!"); //not logged
        return super.onTouchEvent(event);
    }

    private class TouchListener extends GestureDetector.SimpleOnGestureListener 
                                implements View.OnTouchListener{

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            Log.d(TAG, "onTouch: LISTENER!!!"); //logged upon every touch event. twice upon click (for UP and for DOWN)
            gestureDetector.onTouchEvent(event);
            return true; //preventing the view's onTouchEvent from firing
        }

        @Override
        public boolean onSingleTapUp(MotionEvent e) { //you can override onSingleTapConfirmed if you don't want doubleClick to fire it
            Log.d(TAG, "onSingleTapUp: TAP DETECTED"); //logged only upon click
            return true;
        }
    }
}

Exoplayer hide PlaybackControlView onClick (not onTouch), By looking at this answer you can see that an OnTouchListener#onTouch is called BEFORE the View#onTouchEvent so you can set an  This issue is being closed because it does not adhere to our issue template, and/or because it omits information requested in the issue template that is required for us to investigate the problem efficiently.


I am facing same problem but i resolved this problem by flowing set controllerHideOnTouch property of exoplayerview

i used by following line of code

mExoPlayerView!!.controllerHideOnTouch=false

its working for me

Exoplayer hide PlaybackControlView onClick (not onTouch), I am developing a custom ui on top of exoplayer, and I noticed that the controlls (​PlaybackControlView) hide when I touch the screen, not when  @tonihei, I am trying to implement your solution to customize the event which is responsiple for showing playback controls.Unfortunately it is not working. Because controller variable is private and I cannot access it in my own PlayerView.


To always show controls on exo player use hide_on_touch property:

<com.google.android.exoplayer2.ui.PlayerView
    android:id="@+id/video_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:controller_layout_id="@layout/layout_exo_player"
    app:show_timeout="0"
    app:hide_on_touch="false"/>

Exoplayer hide PlaybackControlView onClick (not onTouch), Exoplayer hide PlaybackControlView onClick (not onTouch). Google. 19 August 2017 Posted by asadullahrao. screenshot_20170819-145051 1. PlaybackControlView public PlaybackControlView( Context context, AttributeSet attrs, int defStyleAttr) Deprecated.


PlayerControlView (ExoPlayer library), Direct Known Subclasses: PlaybackControlView Use zero if the controls should not automatically timeout. Corresponding Hides the controller. boolean​  You can use a custom PlaybackControlView to add a fullscreen button to the Exoplayer controls. To toggle the video to fullscreen, you can programmatically remove the SimpleExoPlayerView from your activity and add it to a new fullscreen dialog.


Player.EventListener of SimpleExoPlayer is not working, EventListener of SimpleExoPlayer is not working - android. EventListener but its not working. ExoPlayer has 4 state constants in Player which are Player. OnTouchListener() { #Override public boolean onTouch(View view, MotionEvent OnClickListener() { #Override public void onClick(View v) { Intent intent = new  I want to be able to add animation to PlaybackControlView, however it looks like it is not possible, I tried simpleExoPlayerView.setAnimation(fadeOut) but it does not work. Is there another solution?


ExoPlayer events and UI customizations, In this blog, we will learn how to detect different events of ExoPlayer The feature to customize the ExoPlayer UI components is available from V2.1.0 onwards. PlaybackControlView: It is a view for controlling and managing  Exoplayer hide PlaybackControlView onClick (not onTouch) I am developing a custom ui on top of exoplayer, and I noticed that the controlls (PlaybackControlView) hide when I touch the screen, not when I click. 456