mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 14:20:30 +05:30
Fix service not stopping on play
Listen for player `isPlaying` then stop background service if it is running.
This commit is contained in:
parent
f8676682bf
commit
e1100db58e
@ -194,9 +194,6 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
|||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
context?.hideKeyboard(view)
|
context?.hideKeyboard(view)
|
||||||
|
|
||||||
// Stop [BackgroundMode] service if it is running.
|
|
||||||
BackgroundHelper.stopBackgroundPlay(requireContext())
|
|
||||||
|
|
||||||
// clear the playing queue
|
// clear the playing queue
|
||||||
PlayingQueue.resetToDefaults()
|
PlayingQueue.resetToDefaults()
|
||||||
|
|
||||||
@ -317,8 +314,6 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
binding.playImageView.setOnClickListener {
|
binding.playImageView.setOnClickListener {
|
||||||
// Stop [BackgroundMode] service if it is running.
|
|
||||||
BackgroundHelper.stopBackgroundPlay(requireContext())
|
|
||||||
if (!exoPlayer.isPlaying) {
|
if (!exoPlayer.isPlaying) {
|
||||||
// start or go on playing
|
// start or go on playing
|
||||||
binding.playImageView.setImageResource(R.drawable.ic_pause)
|
binding.playImageView.setImageResource(R.drawable.ic_pause)
|
||||||
@ -819,6 +814,11 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
|||||||
// Listener for play and pause icon change
|
// Listener for play and pause icon change
|
||||||
exoPlayer.addListener(object : Player.Listener {
|
exoPlayer.addListener(object : Player.Listener {
|
||||||
override fun onIsPlayingChanged(isPlaying: Boolean) {
|
override fun onIsPlayingChanged(isPlaying: Boolean) {
|
||||||
|
if (isPlaying) {
|
||||||
|
// Stop [BackgroundMode] service if it is running.
|
||||||
|
BackgroundHelper.stopBackgroundPlay(requireContext())
|
||||||
|
}
|
||||||
|
|
||||||
if (isPlaying && PlayerHelper.sponsorBlockEnabled) {
|
if (isPlaying && PlayerHelper.sponsorBlockEnabled) {
|
||||||
Handler(Looper.getMainLooper()).postDelayed(
|
Handler(Looper.getMainLooper()).postDelayed(
|
||||||
this@PlayerFragment::checkForSegments,
|
this@PlayerFragment::checkForSegments,
|
||||||
|
Loading…
Reference in New Issue
Block a user