fix: pip zoom start player maximized (#640)
* fix zoom * update isZoomEnabled inside updateZoomMode To avoid future issues, I will update `isZoomEnabled` inside `updateZoomMode`. * Revert " update isZoomEnabled inside updateZoomMode" This reverts commit 9b539e1830bc76db0c540a51299f05a09c553d00. * fix: isZoomEnable * val enableZoom for readability * lint
This commit is contained in:
parent
6051fee681
commit
3ba5a73c74
2 changed files with 6 additions and 3 deletions
|
@ -55,6 +55,7 @@ class PlayerActivity : BasePlayerActivity() {
|
||||||
private var playerGestureHelper: PlayerGestureHelper? = null
|
private var playerGestureHelper: PlayerGestureHelper? = null
|
||||||
override val viewModel: PlayerActivityViewModel by viewModels()
|
override val viewModel: PlayerActivityViewModel by viewModels()
|
||||||
private var previewScrubListener: PreviewScrubListener? = null
|
private var previewScrubListener: PreviewScrubListener? = null
|
||||||
|
private var wasZoom: Boolean = false
|
||||||
|
|
||||||
private val isPipSupported by lazy {
|
private val isPipSupported by lazy {
|
||||||
// Check if device has PiP feature
|
// Check if device has PiP feature
|
||||||
|
@ -308,6 +309,7 @@ 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
|
||||||
|
|
||||||
|
wasZoom = playerGestureHelper!!.isZoomEnabled
|
||||||
playerGestureHelper?.updateZoomMode(false)
|
playerGestureHelper?.updateZoomMode(false)
|
||||||
|
|
||||||
// Brightness mode Auto
|
// Brightness mode Auto
|
||||||
|
@ -327,7 +329,7 @@ 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) }
|
playerGestureHelper?.updateZoomMode(wasZoom)
|
||||||
|
|
||||||
// Override auto brightness
|
// Override auto brightness
|
||||||
window.attributes = window.attributes.apply {
|
window.attributes = window.attributes.apply {
|
||||||
|
|
|
@ -330,8 +330,8 @@ class PlayerGestureHelper(
|
||||||
lastScaleEvent = SystemClock.elapsedRealtime()
|
lastScaleEvent = SystemClock.elapsedRealtime()
|
||||||
val scaleFactor = detector.scaleFactor
|
val scaleFactor = detector.scaleFactor
|
||||||
if (abs(scaleFactor - Constants.ZOOM_SCALE_BASE) > Constants.ZOOM_SCALE_THRESHOLD) {
|
if (abs(scaleFactor - Constants.ZOOM_SCALE_BASE) > Constants.ZOOM_SCALE_THRESHOLD) {
|
||||||
isZoomEnabled = scaleFactor > 1
|
val enableZoom = scaleFactor > 1
|
||||||
updateZoomMode(isZoomEnabled)
|
updateZoomMode(enableZoom)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -346,6 +346,7 @@ class PlayerGestureHelper(
|
||||||
} else {
|
} else {
|
||||||
playerView.resizeMode = if (enabled) AspectRatioFrameLayout.RESIZE_MODE_ZOOM else AspectRatioFrameLayout.RESIZE_MODE_FIT
|
playerView.resizeMode = if (enabled) AspectRatioFrameLayout.RESIZE_MODE_ZOOM else AspectRatioFrameLayout.RESIZE_MODE_FIT
|
||||||
}
|
}
|
||||||
|
isZoomEnabled = enabled
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun releaseAction(event: MotionEvent) {
|
private fun releaseAction(event: MotionEvent) {
|
||||||
|
|
Loading…
Reference in a new issue