'How to remove Next and Previous button from SimpleExoPlayerView in Android
I use ExoPlayer to play audio on my Android App with SimpleExoPlayerView as the controller. The default controller have five button, Play/Pause, Forward, Backward, Next, and Previous. My app only use Play/Pause, Forward, and Backward, so I want to remove the Next and Previous button from the controller but I couldn't find how to do it with the SimpleExoPlayerView. How do I achieve this?
Solution 1:[1]
There are default styles for each button. Just override the styles of Previous and Next buttons and add visibility gone.
Put below styles in your style.xml
<style name="ExoMediaButton.Previous">
<item name="android:visibility">gone</item>
</style>
<style name="ExoMediaButton.Next">
<item name="android:visibility">gone</item>
</style>
Solution 2:[2]
Try the following in your style.xml
<style name="ExoMediaButton.Previous">
<item name="android:layout_height">0dp</item>
<item name="android:layout_width">0dp</item>
</style>
<style name="ExoMediaButton.Next">
<item name="android:layout_height">0dp</item>
<item name="android:layout_width">0dp</item>
</style>
Solution 3:[3]
Notice that the visibility of buttons is changed dynamically
So it's better to set zero size of them to fully hide
<ImageButton android:id="@id/exo_prev"
android:layout_width="0dp"
android:layout_height="0dp"
style="@style/ExoMediaButton.Previous"
android:visibility="gone"/>
<ImageButton android:id="@id/exo_rew"
style="@style/ExoMediaButton.Rewind"/>
<ImageButton android:id="@id/exo_shuffle"
style="@style/ExoMediaButton.Shuffle"
android:visibility="gone"/>
<ImageButton android:id="@id/exo_repeat_toggle"
style="@style/ExoMediaButton"
android:visibility="gone"/>
<ImageButton android:id="@id/exo_play"
style="@style/ExoMediaButton.Play"/>
<ImageButton android:id="@id/exo_pause"
style="@style/ExoMediaButton.Pause"/>
<ImageButton android:id="@id/exo_ffwd"
style="@style/ExoMediaButton.FastForward"/>
<ImageButton android:id="@id/exo_next"
android:layout_width="0dp"
android:layout_height="0dp"
style="@style/ExoMediaButton.Next"
android:visibility="gone"/>
<ImageButton android:id="@+id/exo_fullscreen"
android:src="@drawable/fullscreen"
style="@style/ExoMediaButton"/>
<ImageButton android:id="@+id/exo_vr"
style="@style/ExoMediaButton"
android:visibility="gone"/>
Solution 4:[4]
the PlayerView class of exoplayer has two methods to hide those
playerView.setShowNextButton(showNextPrevButtons)
playerView.setShowPreviousButton(showNextPrevButtons)
Solution 5:[5]
You should hideControl(), I also do it.
- Create
CustomSimpleExoPlerViewlikeSimpleExoPlayerView. - Comment all line have
showControl(). - Set
CustomSimpleExoPlayerin xml.
Solution 6:[6]
StyledPlayerView playerView = view.findViewById(R.id.videoPlayer);
playerView.findViewById(R.id.exo_prev).setVisibility(View.GONE);
playerView.findViewById(R.id.exo_next).setVisibility(View.GONE);
This is worked for me!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Lijin |
| Solution 3 | Vlad |
| Solution 4 | Jean Raymond Daher |
| Solution 5 | |
| Solution 6 | Rejsal |
