Search code examples
androidvideoexoplayerexoplayer2.xvisibilitychange

At first only Default time bar disappears after timeout and then again after timeout full controller disappears of Exoplayer


As shown in the image and video, I am facing an issue while using styled player view.

I have set controllerShowTimeoutMs to 2 seconds, but I am getting results as shown in the below image... click to see image

Or as In this video... YouTube link

When the controller don't get any input for 2 seconds, the player's default timebar's visibility is changed.

Then again after 2 seconds all the controls visibility is changed.

I want to make all the controls disappear simultaneously in two seconds.

I tried to check many things but couldn't find the cause of the issue...

Below is the code for Exoplayer in XML

   <com.google.android.exoplayer2.ui.StyledPlayerView
    android:id="@+id/home_exoplayer_view"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    app:controller_layout_id="@layout/exo_control_layout_main"
    app:layout_constraintDimensionRatio="16:9"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:shutter_background_color="?colorTextBackgroundBlack"
    app:use_controller="true"
    app:show_buffering="always"
    app:player_layout_id="@layout/exo_player_layout_main"
    />

And in my fragment

//Autohide controller in below Mili seconds unless the user taps
        exoPlayerView.controllerShowTimeoutMs = 2000

//Don't show controller when playback starts
        exoPlayerView.controllerAutoShow = false

Solution

  • The simple workaround is to disable the animation.Like this

        <com.google.android.exoplayer2.ui.StyledPlayerView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:animation_enabled="false" />
    

    More detail in StyledPlayerControlViewLayoutManager.hide()