mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-06-07 22:48:34 +01:00
feat(mpv): add opaque subtitle background with adjustable opacity (iOS only)
This commit is contained in:
@@ -195,7 +195,8 @@ final class MPVLayerRenderer {
|
||||
// CRITICAL: This option MUST be set immediately after vo=avfoundation, before hwdec options.
|
||||
// On tvOS, moving this elsewhere causes the app to freeze when exiting the player.
|
||||
// - iOS: "yes" for PiP subtitle support (subtitles baked into video)
|
||||
// - tvOS: "no" to prevent gray tint + frame drops with subtitles
|
||||
// - tvOS: "no" - composite OSD breaks subtitle rendering entirely on tvOS
|
||||
// Note: This means subtitle styling (background colors) won't work on tvOS
|
||||
#if os(tvOS)
|
||||
checkError(mpv_set_option_string(handle, "avfoundation-composite-osd", "no"))
|
||||
#else
|
||||
@@ -820,7 +821,22 @@ final class MPVLayerRenderer {
|
||||
func setSubtitleFontSize(_ size: Int) {
|
||||
setProperty(name: "sub-font-size", value: String(size))
|
||||
}
|
||||
|
||||
|
||||
func setSubtitleBackgroundColor(_ color: String) {
|
||||
setProperty(name: "sub-back-color", value: color)
|
||||
}
|
||||
|
||||
func setSubtitleBorderStyle(_ style: String) {
|
||||
// "outline-and-shadow" (default) or "background-box" (enables background color)
|
||||
setProperty(name: "sub-border-style", value: style)
|
||||
}
|
||||
|
||||
func setSubtitleAssOverride(_ mode: String) {
|
||||
// Controls whether to override ASS subtitle styles
|
||||
// "no" = keep ASS styles, "force" = override with user settings
|
||||
setProperty(name: "sub-ass-override", value: mode)
|
||||
}
|
||||
|
||||
// MARK: - Audio Track Controls
|
||||
|
||||
func getAudioTracks() -> [[String: Any]] {
|
||||
|
||||
@@ -157,7 +157,19 @@ public class MpvPlayerModule: Module {
|
||||
AsyncFunction("setSubtitleFontSize") { (view: MpvPlayerView, size: Int) in
|
||||
view.setSubtitleFontSize(size)
|
||||
}
|
||||
|
||||
|
||||
AsyncFunction("setSubtitleBackgroundColor") { (view: MpvPlayerView, color: String) in
|
||||
view.setSubtitleBackgroundColor(color)
|
||||
}
|
||||
|
||||
AsyncFunction("setSubtitleBorderStyle") { (view: MpvPlayerView, style: String) in
|
||||
view.setSubtitleBorderStyle(style)
|
||||
}
|
||||
|
||||
AsyncFunction("setSubtitleAssOverride") { (view: MpvPlayerView, mode: String) in
|
||||
view.setSubtitleAssOverride(mode)
|
||||
}
|
||||
|
||||
// Audio track functions
|
||||
AsyncFunction("getAudioTracks") { (view: MpvPlayerView) -> [[String: Any]] in
|
||||
return view.getAudioTracks()
|
||||
|
||||
@@ -319,6 +319,18 @@ class MpvPlayerView: ExpoView {
|
||||
renderer?.setSubtitleFontSize(size)
|
||||
}
|
||||
|
||||
func setSubtitleBackgroundColor(_ color: String) {
|
||||
renderer?.setSubtitleBackgroundColor(color)
|
||||
}
|
||||
|
||||
func setSubtitleBorderStyle(_ style: String) {
|
||||
renderer?.setSubtitleBorderStyle(style)
|
||||
}
|
||||
|
||||
func setSubtitleAssOverride(_ mode: String) {
|
||||
renderer?.setSubtitleAssOverride(mode)
|
||||
}
|
||||
|
||||
// MARK: - Video Scaling
|
||||
|
||||
func setZoomedToFill(_ zoomed: Bool) {
|
||||
|
||||
Reference in New Issue
Block a user