fix: pip remember zoom and auto-brightness (#638)
This commit is contained in:
parent
61ec1edb35
commit
c67f6c265b
2 changed files with 21 additions and 8 deletions
|
@ -12,6 +12,7 @@ import android.media.AudioManager
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Process
|
import android.os.Process
|
||||||
|
import android.provider.Settings
|
||||||
import android.util.Rational
|
import android.util.Rational
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
|
@ -27,7 +28,6 @@ import androidx.lifecycle.Lifecycle
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.lifecycle.repeatOnLifecycle
|
import androidx.lifecycle.repeatOnLifecycle
|
||||||
import androidx.media3.common.C
|
import androidx.media3.common.C
|
||||||
import androidx.media3.ui.AspectRatioFrameLayout
|
|
||||||
import androidx.media3.ui.DefaultTimeBar
|
import androidx.media3.ui.DefaultTimeBar
|
||||||
import androidx.media3.ui.PlayerView
|
import androidx.media3.ui.PlayerView
|
||||||
import androidx.navigation.navArgs
|
import androidx.navigation.navArgs
|
||||||
|
@ -35,7 +35,6 @@ import dagger.hilt.android.AndroidEntryPoint
|
||||||
import dev.jdtech.jellyfin.databinding.ActivityPlayerBinding
|
import dev.jdtech.jellyfin.databinding.ActivityPlayerBinding
|
||||||
import dev.jdtech.jellyfin.dialogs.SpeedSelectionDialogFragment
|
import dev.jdtech.jellyfin.dialogs.SpeedSelectionDialogFragment
|
||||||
import dev.jdtech.jellyfin.dialogs.TrackSelectionDialogFragment
|
import dev.jdtech.jellyfin.dialogs.TrackSelectionDialogFragment
|
||||||
import dev.jdtech.jellyfin.mpv.MPVPlayer
|
|
||||||
import dev.jdtech.jellyfin.utils.PlayerGestureHelper
|
import dev.jdtech.jellyfin.utils.PlayerGestureHelper
|
||||||
import dev.jdtech.jellyfin.utils.PreviewScrubListener
|
import dev.jdtech.jellyfin.utils.PreviewScrubListener
|
||||||
import dev.jdtech.jellyfin.viewmodels.PlayerActivityViewModel
|
import dev.jdtech.jellyfin.viewmodels.PlayerActivityViewModel
|
||||||
|
@ -309,10 +308,11 @@ class PlayerActivity : BasePlayerActivity() {
|
||||||
binding.playerView.useController = false
|
binding.playerView.useController = false
|
||||||
binding.playerView.findViewById<Button>(R.id.btn_skip_intro).isVisible = false
|
binding.playerView.findViewById<Button>(R.id.btn_skip_intro).isVisible = false
|
||||||
|
|
||||||
if (binding.playerView.player is MPVPlayer) {
|
playerGestureHelper?.updateZoomMode(false)
|
||||||
(binding.playerView.player as MPVPlayer).updateZoomMode(false)
|
|
||||||
} else {
|
// Brightness mode Auto
|
||||||
binding.playerView.resizeMode = AspectRatioFrameLayout.RESIZE_MODE_FIT
|
window.attributes = window.attributes.apply {
|
||||||
|
screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -327,6 +327,19 @@ class PlayerActivity : BasePlayerActivity() {
|
||||||
super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig)
|
super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig)
|
||||||
if (!isInPictureInPictureMode) {
|
if (!isInPictureInPictureMode) {
|
||||||
binding.playerView.useController = true
|
binding.playerView.useController = true
|
||||||
|
playerGestureHelper?.isZoomEnabled?.let { playerGestureHelper!!.updateZoomMode(it) }
|
||||||
|
|
||||||
|
// Override auto brightness
|
||||||
|
window.attributes = window.attributes.apply {
|
||||||
|
screenBrightness = if (appPreferences.playerBrightnessRemember) {
|
||||||
|
appPreferences.playerBrightness
|
||||||
|
} else {
|
||||||
|
Settings.System.getInt(
|
||||||
|
contentResolver,
|
||||||
|
Settings.System.SCREEN_BRIGHTNESS,
|
||||||
|
).toFloat() / 255
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ class PlayerGestureHelper(
|
||||||
* Tracks whether video content should fill the screen, cutting off unwanted content on the sides.
|
* Tracks whether video content should fill the screen, cutting off unwanted content on the sides.
|
||||||
* Useful on wide-screen phones to remove black bars from some movies.
|
* Useful on wide-screen phones to remove black bars from some movies.
|
||||||
*/
|
*/
|
||||||
private var isZoomEnabled = false
|
var isZoomEnabled = false
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tracks a value during a swipe gesture (between multiple onScroll calls).
|
* Tracks a value during a swipe gesture (between multiple onScroll calls).
|
||||||
|
@ -340,7 +340,7 @@ class PlayerGestureHelper(
|
||||||
},
|
},
|
||||||
).apply { isQuickScaleEnabled = false }
|
).apply { isQuickScaleEnabled = false }
|
||||||
|
|
||||||
private fun updateZoomMode(enabled: Boolean) {
|
fun updateZoomMode(enabled: Boolean) {
|
||||||
if (playerView.player is MPVPlayer) {
|
if (playerView.player is MPVPlayer) {
|
||||||
(playerView.player as MPVPlayer).updateZoomMode(enabled)
|
(playerView.player as MPVPlayer).updateZoomMode(enabled)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue