fix(ios): enable PiP subtitles
This commit is contained in:
@@ -789,7 +789,7 @@
|
||||
repositoryURL = "https://github.com/edde746/MPVKit";
|
||||
requirement = {
|
||||
kind = revision;
|
||||
revision = 42dcc3123000361d0be54fbaec981043b77e1e05;
|
||||
revision = 8da57fe1d3dd82524ea4b2ef6ef8b2d692ada395;
|
||||
};
|
||||
};
|
||||
/* End XCRemoteSwiftPackageReference section */
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/edde746/MPVKit",
|
||||
"state" : {
|
||||
"revision" : "42dcc3123000361d0be54fbaec981043b77e1e05"
|
||||
"revision" : "8da57fe1d3dd82524ea4b2ef6ef8b2d692ada395"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/edde746/MPVKit",
|
||||
"state" : {
|
||||
"revision" : "42dcc3123000361d0be54fbaec981043b77e1e05"
|
||||
"revision" : "8da57fe1d3dd82524ea4b2ef6ef8b2d692ada395"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -188,6 +188,7 @@ class MpvPlayerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, MpvPluginS
|
||||
guard let playerCore = playerCore else { return nil }
|
||||
guard let pip = ensurePipController() else { return nil }
|
||||
pendingInlineRestoreAfterPip = false
|
||||
playerCore.setPipSubtitleCompositing(true)
|
||||
playerCore.isPipStarting = true
|
||||
pip.syncTimebase(currentTime: playerCore.timePos, isPlaying: !playerCore.isPaused)
|
||||
pip.invalidatePlaybackState()
|
||||
@@ -232,6 +233,7 @@ class MpvPlayerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, MpvPluginS
|
||||
|
||||
/// Unified cleanup for all PiP exit paths
|
||||
private func cleanupPip(notify: Bool, pause: Bool = false) {
|
||||
playerCore?.setPipSubtitleCompositing(false)
|
||||
playerCore?.isPipStarting = false
|
||||
playerCore?.isPipActive = false
|
||||
isManualPipRequest = false
|
||||
|
||||
@@ -426,6 +426,22 @@ class MpvPlayerCoreBase: NSObject {
|
||||
}
|
||||
}
|
||||
|
||||
/// PiP presents the AVSampleBufferDisplayLayer directly, so subtitles must
|
||||
/// be composited into the video samples instead of the inline OSD layer.
|
||||
func setPipSubtitleCompositing(_ enabled: Bool) {
|
||||
#if os(iOS)
|
||||
let value = enabled ? "yes" : "no"
|
||||
setRawStringPropertyAsync("avfoundation-pip-composite-osd", value: value) { result in
|
||||
if case .failure(let error) = result {
|
||||
print(
|
||||
"[MpvPlayerCore] Failed to set PiP subtitle compositing "
|
||||
+ "to \(value): \(error.localizedDescription)"
|
||||
)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
func getPropertyAsync(_ name: String, completion: @escaping (Result<String?, Error>) -> Void) {
|
||||
guard let mpv else {
|
||||
completion(.success(nil))
|
||||
@@ -611,7 +627,7 @@ class MpvPlayerCoreBase: NSObject {
|
||||
|
||||
private func isManagedRendererProperty(_ name: String) -> Bool {
|
||||
name == "vo" || name == "wid" || name == "gpu-api" || name == "gpu-context"
|
||||
|| name == "avfoundation-composite-osd"
|
||||
|| name == "avfoundation-composite-osd" || name == "avfoundation-pip-composite-osd"
|
||||
}
|
||||
|
||||
private func updateVideoGravityIfNeeded(name: String, value: String) {
|
||||
|
||||
Reference in New Issue
Block a user