Set default subtitle styling

This commit is contained in:
Damontecres 2025-11-08 13:35:37 -05:00
parent 32712c39a0
commit e982119237
No known key found for this signature in database

View file

@ -9,6 +9,7 @@ import android.view.SurfaceHolder
import android.view.SurfaceView
import android.view.TextureView
import androidx.annotation.OptIn
import androidx.compose.ui.graphics.Color
import androidx.media3.common.AudioAttributes
import androidx.media3.common.BasePlayer
import androidx.media3.common.C
@ -104,6 +105,16 @@ class MpvPlayer(
MPVLib.setOptionString("demuxer-max-bytes", "${cacheMegs * 1024 * 1024}")
MPVLib.setOptionString("demuxer-max-back-bytes", "${cacheMegs * 1024 * 1024}")
// TODO make configurable
// Subtitle styling
MPVLib.setPropertyInt("sub-font-size", 56)
MPVLib.setPropertyColor("sub-color", Color.White)
MPVLib.setPropertyColor("sub-outline-color", Color.Black)
MPVLib.setPropertyDouble("sub-outline-size", 1.65)
// sub-back-color
// sub-border-style
MPVLib.init()
MPVLib.setOptionString("force-window", "no")
@ -724,4 +735,15 @@ class MpvPlayer(
override fun onTrackSelectionsInvalidated() {
// no-op
}
var subtitleDelay: Double
get() = MPVLib.getPropertyDouble("sub-delay") ?: 0.0
set(value) = MPVLib.setPropertyDouble("sub-delay", value)
}
private fun MPVLib.setPropertyColor(
property: String,
color: Color,
) = MPVLib.setPropertyString(property, color.mpvFormat)
private val Color.mpvFormat: String get() = "$red/$green/$blue/$alpha"