Fix "pinch to zoom" for MPV (#144)

Closes #22
This commit is contained in:
Yusuf 2022-08-22 20:08:35 +03:00 committed by GitHub
parent 17676c0a60
commit a5189eb4fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View file

@ -1230,6 +1230,11 @@ class MPVPlayer(
throw IllegalArgumentException("You should use global volume controls. Check out AUDIO_SERVICE.")
}
fun updateZoomMode(enabled: Boolean) {
val level = if (enabled) "1" else "0"
MPVLib.setOptionString("panscan", level)
}
companion object {
/**
* Fraction to which audio volume is ducked on loss of audio focus

View file

@ -11,6 +11,7 @@ import android.view.WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_OFF
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout
import com.google.android.exoplayer2.ui.StyledPlayerView
import dev.jdtech.jellyfin.PlayerActivity
import dev.jdtech.jellyfin.mpv.MPVPlayer
import timber.log.Timber
import kotlin.math.abs
@ -199,7 +200,12 @@ class PlayerGestureHelper(
}).apply { isQuickScaleEnabled = false }
private fun updateZoomMode(enabled: Boolean) {
playerView.resizeMode = if (enabled) AspectRatioFrameLayout.RESIZE_MODE_ZOOM else AspectRatioFrameLayout.RESIZE_MODE_FIT
if (playerView.player is MPVPlayer) {
(playerView.player as MPVPlayer).updateZoomMode(enabled)
}
else {
playerView.resizeMode = if (enabled) AspectRatioFrameLayout.RESIZE_MODE_ZOOM else AspectRatioFrameLayout.RESIZE_MODE_FIT
}
}
private fun releaseAction(event: MotionEvent) {