mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 14:20:30 +05:30
fix: multiple seekbar listeners interfering with each other
This commit is contained in:
parent
f0fd37e690
commit
1efe09d492
@ -183,11 +183,8 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
private var sponsorBlockConfig = PlayerHelper.getSponsorBlockCategories()
|
private var sponsorBlockConfig = PlayerHelper.getSponsorBlockCategories()
|
||||||
|
|
||||||
private val handler = Handler(Looper.getMainLooper())
|
private val handler = Handler(Looper.getMainLooper())
|
||||||
private val mainActivity get() = activity as MainActivity
|
|
||||||
private val windowInsetsControllerCompat
|
|
||||||
get() = WindowCompat
|
|
||||||
.getInsetsController(mainActivity.window, mainActivity.window.decorView)
|
|
||||||
|
|
||||||
|
private var seekBarPreviewListener: SeekbarPreviewListener? = null
|
||||||
private var scrubbingTimeBar = false
|
private var scrubbingTimeBar = false
|
||||||
private var chaptersBottomSheet: ChaptersBottomSheet? = null
|
private var chaptersBottomSheet: ChaptersBottomSheet? = null
|
||||||
|
|
||||||
@ -197,6 +194,11 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
*/
|
*/
|
||||||
private var playerLayoutOrientation = Int.MIN_VALUE
|
private var playerLayoutOrientation = Int.MIN_VALUE
|
||||||
|
|
||||||
|
private val mainActivity get() = activity as MainActivity
|
||||||
|
private val windowInsetsControllerCompat
|
||||||
|
get() = WindowCompat
|
||||||
|
.getInsetsController(mainActivity.window, mainActivity.window.decorView)
|
||||||
|
|
||||||
private val fullscreenDialog by lazy {
|
private val fullscreenDialog by lazy {
|
||||||
object : Dialog(requireContext(), android.R.style.Theme_Black_NoTitleBar_Fullscreen) {
|
object : Dialog(requireContext(), android.R.style.Theme_Black_NoTitleBar_Fullscreen) {
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
@ -758,7 +760,6 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
playerBinding.exoProgress.setPlayer(exoPlayer)
|
playerBinding.exoProgress.setPlayer(exoPlayer)
|
||||||
|
|
||||||
initializePlayerView()
|
initializePlayerView()
|
||||||
setupSeekbarPreview()
|
|
||||||
|
|
||||||
exoPlayer.playWhenReady = PlayerHelper.playAutomatically
|
exoPlayer.playWhenReady = PlayerHelper.playAutomatically
|
||||||
exoPlayer.prepare()
|
exoPlayer.prepare()
|
||||||
@ -1020,6 +1021,13 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
playerBinding.skipNext.setOnClickListener {
|
playerBinding.skipNext.setOnClickListener {
|
||||||
playNextVideo()
|
playNextVideo()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// seekbar preview setup
|
||||||
|
playerBinding.seekbarPreview.isGone = true
|
||||||
|
seekBarPreviewListener?.let { playerBinding.exoProgress.removeListener(it) }
|
||||||
|
seekBarPreviewListener = createSeekbarPreviewListener().also {
|
||||||
|
playerBinding.exoProgress.addListener(it)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showAutoPlayCountdown() {
|
private fun showAutoPlayCountdown() {
|
||||||
@ -1531,10 +1539,8 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
}
|
}
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
private fun setupSeekbarPreview() {
|
private fun createSeekbarPreviewListener(): SeekbarPreviewListener {
|
||||||
playerBinding.seekbarPreview.isGone = true
|
return SeekbarPreviewListener(
|
||||||
playerBinding.exoProgress.addListener(
|
|
||||||
SeekbarPreviewListener(
|
|
||||||
OnlineTimeFrameReceiver(requireContext(), streams.previewFrames),
|
OnlineTimeFrameReceiver(requireContext(), streams.previewFrames),
|
||||||
playerBinding,
|
playerBinding,
|
||||||
streams.duration * 1000,
|
streams.duration * 1000,
|
||||||
@ -1547,7 +1553,6 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
setCurrentChapterName(forceUpdate = true, enqueueNew = false)
|
setCurrentChapterName(forceUpdate = true, enqueueNew = false)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user