Revert "hell yeah"

This reverts commit 7e1d10aa08.
This commit is contained in:
Francesco 2025-06-03 18:04:32 +02:00
parent dd4bb5f437
commit 771e67e9d2
2 changed files with 7 additions and 17 deletions

View file

@ -41,7 +41,6 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
var currentTimeVal: Double = 0.0
var duration: Double = 0.0
var isVideoLoaded = false
var detachedWindow: UIWindow?
private var isHoldPauseEnabled: Bool {
UserDefaults.standard.bool(forKey: "holdForPauseEnabled")

View file

@ -1393,7 +1393,13 @@ struct MediaInfoView: View {
customMediaPlayer.modalPresentationStyle = .fullScreen
Logger.shared.log("Opening custom media player with url: \(url)")
presentPlayerWithDetachedContext(customMediaPlayer: customMediaPlayer)
if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
let rootVC = windowScene.windows.first?.rootViewController {
rootVC.present(customMediaPlayer, animated: true, completion: nil)
} else {
Logger.shared.log("Failed to find root view controller", type: "Error")
DropManager.shared.showDrop(title: "Error", subtitle: "Failed to present player", duration: 2.0, icon: UIImage(systemName: "xmark.circle"))
}
}
}
}
@ -1975,19 +1981,4 @@ struct MediaInfoView: View {
videoPlayerViewController.detachedWindow = detachedWindow
hostingController.present(videoPlayerViewController, animated: true, completion: nil)
}
private func presentPlayerWithDetachedContext(customMediaPlayer: CustomMediaPlayerViewController) {
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene else { return }
let detachedWindow = UIWindow(windowScene: windowScene)
let hostingController = UIViewController()
hostingController.view.backgroundColor = .clear
detachedWindow.rootViewController = hostingController
detachedWindow.backgroundColor = .clear
detachedWindow.windowLevel = .normal + 1
detachedWindow.makeKeyAndVisible()
customMediaPlayer.detachedWindow = detachedWindow
hostingController.present(customMediaPlayer, animated: true, completion: nil)
}
}