mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-27 15:30:31 +05:30
Change play pause implementation to use a single image button
Remove `exo_play_pause` and make use of the custom image view gives more accessibility
This commit is contained in:
parent
9dd505917d
commit
bf1d9d46ba
@ -315,16 +315,9 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
||||
BackgroundHelper.stopBackgroundPlay(requireContext())
|
||||
}
|
||||
|
||||
playerBinding.repeatBTN.setOnClickListener {
|
||||
// Restart video if finished
|
||||
exoPlayer.seekTo(0)
|
||||
exoPlayer.play()
|
||||
}
|
||||
|
||||
binding.playImageView.setOnClickListener {
|
||||
val playPauseClickListner = View.OnClickListener {
|
||||
if (!exoPlayer.isPlaying) {
|
||||
// start or go on playing
|
||||
binding.playImageView.setImageResource(R.drawable.ic_pause)
|
||||
if (exoPlayer.playbackState == Player.STATE_ENDED) {
|
||||
// restart video if finished
|
||||
exoPlayer.seekTo(0)
|
||||
@ -332,10 +325,11 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
||||
exoPlayer.play()
|
||||
} else {
|
||||
// pause the video
|
||||
binding.playImageView.setImageResource(R.drawable.ic_play)
|
||||
exoPlayer.pause()
|
||||
}
|
||||
}
|
||||
playerBinding.playPauseBTN.setOnClickListener(playPauseClickListner)
|
||||
binding.playImageView.setOnClickListener(playPauseClickListner)
|
||||
|
||||
// video description and chapters toggle
|
||||
binding.playerTitleLayout.setOnClickListener {
|
||||
@ -977,18 +971,15 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
||||
if (exoPlayer.isPlaying) {
|
||||
// video is playing
|
||||
binding.playImageView.setImageResource(R.drawable.ic_pause)
|
||||
playerBinding.exoPlayPause.visibility = View.VISIBLE
|
||||
playerBinding.repeatBTN.visibility = View.GONE
|
||||
playerBinding.playPauseBTN.setImageResource(R.drawable.ic_pause)
|
||||
} else if (exoPlayer.playbackState == Player.STATE_ENDED) {
|
||||
// video has finished
|
||||
binding.playImageView.setImageResource(R.drawable.ic_restart)
|
||||
playerBinding.exoPlayPause.visibility = View.GONE
|
||||
playerBinding.repeatBTN.visibility = View.VISIBLE
|
||||
playerBinding.playPauseBTN.setImageResource(R.drawable.ic_restart)
|
||||
} else {
|
||||
// player in any other state
|
||||
binding.playImageView.setImageResource(R.drawable.ic_play)
|
||||
playerBinding.exoPlayPause.visibility = View.VISIBLE
|
||||
playerBinding.repeatBTN.visibility = View.GONE
|
||||
playerBinding.playPauseBTN.setImageResource(R.drawable.ic_play)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -272,7 +272,7 @@ internal class CustomExoPlayerView(
|
||||
binding.exoBottomBar.visibility = visibility
|
||||
binding.closeImageButton.visibility = visibility
|
||||
binding.exoTitle.visibility = visibility
|
||||
binding.exoPlayPause.visibility = visibility
|
||||
binding.playPauseBTN.visibility = visibility
|
||||
|
||||
// disable tap and swipe gesture if the player is locked
|
||||
playerGestureController.isEnabled = isLocked
|
||||
|
@ -277,20 +277,12 @@
|
||||
</FrameLayout>
|
||||
|
||||
<ImageButton
|
||||
android:id="@id/exo_play_pause"
|
||||
android:id="@+id/playPauseBTN"
|
||||
style="@style/ExoStyledControls.Button.Center.PlayPause"
|
||||
android:layout_marginHorizontal="10dp"
|
||||
android:background="?android:selectableItemBackgroundBorderless"
|
||||
app:tint="@android:color/white" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/repeatBTN"
|
||||
style="@style/ExoStyledControls.Button.Center.PlayPause"
|
||||
android:layout_marginHorizontal="10dp"
|
||||
android:background="?android:selectableItemBackgroundBorderless"
|
||||
android:src="@drawable/ic_restart"
|
||||
app:tint="@android:color/white" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/forwardBTN"
|
||||
android:layout_width="wrap_content"
|
||||
|
Loading…
x
Reference in New Issue
Block a user