refactor(exoplayer): drop duplicated mpv box-fit translation

This commit is contained in:
edde746
2026-04-21 18:23:46 +02:00
parent 839465b7f2
commit e6c1923b0e
2 changed files with 7 additions and 35 deletions
@@ -519,40 +519,10 @@ class ExoPlayerPlugin : FlutterPlugin, MethodChannel.MethodCallHandler,
result.error("INVALID_ARGS", "Missing 'mode'", null)
return
}
// Translate mode to MPV properties so the fallback path (and any
// future fallback from this session) stays in sync with the UI state.
// Mirrors VideoFilterManager.updateVideoFilter's MPV branch.
val mpvProps = when (mode) {
1 -> listOf(
"video-aspect-override" to "no",
"panscan" to "1.0",
"sub-ass-force-margins" to "yes",
)
2 -> {
val act = activity
val aspect = if (act != null) {
val dm = act.resources.displayMetrics
if (dm.heightPixels > 0) dm.widthPixels.toFloat() / dm.heightPixels else 0f
} else 0f
listOf(
"video-aspect-override" to (if (aspect > 0) aspect.toString() else "no"),
"panscan" to "0",
"sub-ass-force-margins" to "no",
)
}
else -> listOf(
"video-aspect-override" to "no",
"panscan" to "0",
"sub-ass-force-margins" to "no",
)
}
val keys = mpvProps.map { it.first }.toSet()
pendingMpvProperties.removeAll { it.first in keys }
pendingMpvProperties.addAll(mpvProps)
// The MPV-property side (panscan / sub-ass-force-margins / video-aspect-override)
// is driven from Dart via setProperty and routed through setMpvProperty, which
// already handles both the fallback and pendingMpvProperties cases.
if (usingMpvFallback) {
mpvProps.forEach { (k, v) -> mpvCore?.setProperty(k, v) }
result.success(null)
return
}
+4 -2
View File
@@ -134,9 +134,11 @@ class VideoFilterManager {
/// When ambient lighting is active, video-aspect-override is managed by ambient lighting.
void updateVideoFilter() async {
try {
if (player.playerType == 'exoplayer') {
// ExoPlayer handles scaling via AspectRatioFrameLayout. The MPV properties
// below still run — on PlayerAndroid they forward to setMpvProperty, which
// queues them for any future fallback to MPV.
if (player is PlayerAndroid) {
await (player as PlayerAndroid).setBoxFitMode(_boxFitMode);
return;
}
if (ambientLightingService?.isEnabled != true) {