mirror of
https://github.com/cranci1/Sora.git
synced 2026-04-21 08:32:00 +00:00
added external player
This commit is contained in:
parent
586e9731f8
commit
d16c009360
1 changed files with 28 additions and 7 deletions
|
|
@ -372,14 +372,35 @@ struct MediaInfoView: View {
|
||||||
|
|
||||||
func playStream(url: String, fullURL: String) {
|
func playStream(url: String, fullURL: String) {
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
let videoPlayerViewController = VideoPlayerViewController(module: module)
|
let externalPlayer = UserDefaults.standard.string(forKey: "externalPlayer") ?? "Default"
|
||||||
videoPlayerViewController.streamUrl = url
|
var scheme: String?
|
||||||
videoPlayerViewController.fullUrl = fullURL
|
|
||||||
videoPlayerViewController.modalPresentationStyle = .fullScreen
|
|
||||||
|
|
||||||
if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
|
switch externalPlayer {
|
||||||
let rootVC = windowScene.windows.first?.rootViewController {
|
case "Infuse":
|
||||||
rootVC.present(videoPlayerViewController, animated: true, completion: nil)
|
scheme = "infuse://x-callback-url/play?url=\(url)"
|
||||||
|
case "VLC":
|
||||||
|
scheme = "vlc://\(url)"
|
||||||
|
case "OutPlayer":
|
||||||
|
scheme = "outplayer://\(url)"
|
||||||
|
case "nPlayer":
|
||||||
|
scheme = "nplayer-\(url)"
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if let scheme = scheme, let url = URL(string: scheme), UIApplication.shared.canOpenURL(url) {
|
||||||
|
UIApplication.shared.open(url, options: [:], completionHandler: nil)
|
||||||
|
Logger.shared.log("Opening external app with scheme: \(url)", type: "General")
|
||||||
|
} else {
|
||||||
|
let videoPlayerViewController = VideoPlayerViewController(module: module)
|
||||||
|
videoPlayerViewController.streamUrl = url
|
||||||
|
videoPlayerViewController.fullUrl = fullURL
|
||||||
|
videoPlayerViewController.modalPresentationStyle = .fullScreen
|
||||||
|
|
||||||
|
if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
|
||||||
|
let rootVC = windowScene.windows.first?.rootViewController {
|
||||||
|
rootVC.present(videoPlayerViewController, animated: true, completion: nil)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue