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