mirror of
https://github.com/cranci1/Sora.git
synced 2026-04-14 05:20:25 +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) {
|
||||
DispatchQueue.main.async {
|
||||
let videoPlayerViewController = VideoPlayerViewController(module: module)
|
||||
videoPlayerViewController.streamUrl = url
|
||||
videoPlayerViewController.fullUrl = fullURL
|
||||
videoPlayerViewController.modalPresentationStyle = .fullScreen
|
||||
let externalPlayer = UserDefaults.standard.string(forKey: "externalPlayer") ?? "Default"
|
||||
var scheme: String?
|
||||
|
||||
if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
|
||||
let rootVC = windowScene.windows.first?.rootViewController {
|
||||
rootVC.present(videoPlayerViewController, animated: true, completion: nil)
|
||||
switch externalPlayer {
|
||||
case "Infuse":
|
||||
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