mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-13 05:40:31 +05:30
Merge pull request #5697 from Bnyro/master
fix: paused video autoplays when unlock screen after few minutes locked
This commit is contained in:
commit
4ead29e7c4
@ -41,4 +41,5 @@ object IntentData {
|
||||
const val maxAudioQuality = "maxAudioQuality"
|
||||
const val audioLanguage = "audioLanguage"
|
||||
const val captionLanguage = "captionLanguage"
|
||||
const val wasIntentStopped = "wasIntentStopped"
|
||||
}
|
||||
|
@ -113,7 +113,6 @@ import com.github.libretube.util.PlayingQueue
|
||||
import com.github.libretube.util.TextUtils
|
||||
import com.github.libretube.util.TextUtils.toTimeInSeconds
|
||||
import com.github.libretube.util.YoutubeHlsPlaylistParser
|
||||
import java.util.*
|
||||
import java.util.concurrent.Executors
|
||||
import kotlin.math.abs
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@ -782,6 +781,11 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
||||
) {
|
||||
exoPlayer.pause()
|
||||
}
|
||||
|
||||
// the app was put somewhere in the background - remember to not automatically continue
|
||||
// playing on re-creation of the app
|
||||
requireArguments().putBoolean(IntentData.wasIntentStopped, true)
|
||||
|
||||
super.onPause()
|
||||
}
|
||||
|
||||
@ -948,7 +952,11 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
||||
|
||||
initializePlayerView()
|
||||
|
||||
exoPlayer.playWhenReady = PlayerHelper.playAutomatically
|
||||
// don't continue playback when the fragment is re-created after Android killed it
|
||||
val wasIntentStopped = requireArguments().getBoolean(IntentData.wasIntentStopped, false)
|
||||
exoPlayer.playWhenReady = PlayerHelper.playAutomatically && !wasIntentStopped
|
||||
requireArguments().putBoolean(IntentData.wasIntentStopped, false)
|
||||
|
||||
exoPlayer.prepare()
|
||||
|
||||
if (binding.playerMotionLayout.progress != 1.0f) {
|
||||
|
Loading…
Reference in New Issue
Block a user