mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-15 06:40:30 +05:30
commit
852a3311b3
@ -512,11 +512,7 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
|||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
try {
|
try {
|
||||||
// disable the auto PiP mode for SDK >= 32
|
// disable the auto PiP mode for SDK >= 32
|
||||||
if (SDK_INT >= Build.VERSION_CODES.S) {
|
disableAutoPiP()
|
||||||
activity?.setPictureInPictureParams(
|
|
||||||
PictureInPictureParams.Builder().setAutoEnterEnabled(false).build()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
saveWatchPosition()
|
saveWatchPosition()
|
||||||
|
|
||||||
@ -535,6 +531,15 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun disableAutoPiP() {
|
||||||
|
if (SDK_INT < Build.VERSION_CODES.S) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
activity?.setPictureInPictureParams(
|
||||||
|
PictureInPictureParams.Builder().setAutoEnterEnabled(false).build()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// save the watch position if video isn't finished and option enabled
|
// save the watch position if video isn't finished and option enabled
|
||||||
private fun saveWatchPosition() {
|
private fun saveWatchPosition() {
|
||||||
if (!PlayerHelper.watchPositionsEnabled) return
|
if (!PlayerHelper.watchPositionsEnabled) return
|
||||||
@ -848,7 +853,7 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
|||||||
) {
|
) {
|
||||||
transitioning = true
|
transitioning = true
|
||||||
// check whether autoplay is enabled
|
// check whether autoplay is enabled
|
||||||
if (binding.player.autoplayEnabled) playNextVideo()
|
playNextVideo()
|
||||||
}
|
}
|
||||||
|
|
||||||
when (playbackState) {
|
when (playbackState) {
|
||||||
@ -873,6 +878,7 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
|||||||
query {
|
query {
|
||||||
Database.watchPositionDao().insertAll(watchPosition)
|
Database.watchPositionDao().insertAll(watchPosition)
|
||||||
}
|
}
|
||||||
|
disableAutoPiP()
|
||||||
}
|
}
|
||||||
|
|
||||||
// listen for the stop button in the notification
|
// listen for the stop button in the notification
|
||||||
@ -1463,8 +1469,7 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
|||||||
|
|
||||||
val backgroundModeRunning = isServiceRunning(requireContext(), BackgroundMode::class.java)
|
val backgroundModeRunning = isServiceRunning(requireContext(), BackgroundMode::class.java)
|
||||||
|
|
||||||
return viewModel.isFullscreen.value == true &&
|
return exoPlayer.isPlaying && !backgroundModeRunning
|
||||||
(exoPlayer.isPlaying || !backgroundModeRunning)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isServiceRunning(context: Context, serviceClass: Class<*>): Boolean {
|
private fun isServiceRunning(context: Context, serviceClass: Class<*>): Boolean {
|
||||||
|
Loading…
Reference in New Issue
Block a user