fix native playback build blockers

This commit is contained in:
dirtydishes 2026-05-24 23:23:14 -04:00
parent d28540ce98
commit b15e4d640e
5 changed files with 48 additions and 2 deletions

View file

@ -54,7 +54,7 @@ final class DreamioWebViewController: UIViewController {
private var lastNativePlaybackURL: URL?
private static let streamCandidateScript = WKUserScript(
source: """
source: #"""
(() => {
if (window.__dreamioStreamBridgeInstalled) {
return;
@ -181,7 +181,7 @@ final class DreamioWebViewController: UIViewController {
inspectMedia(document);
})();
""",
"""#,
injectionTime: .atDocumentStart,
forMainFrameOnly: false
)

View file

@ -1,24 +1,34 @@
import UIKit
#if canImport(MobileVLCKit)
import MobileVLCKit
#endif
final class VLCNativePlaybackBackend: NSObject, NativePlaybackBackend {
let view = UIView()
var onReady: (() -> Void)?
var onFailure: ((Error) -> Void)?
#if canImport(MobileVLCKit)
private let mediaPlayer = VLCMediaPlayer()
#endif
override init() {
super.init()
#if canImport(MobileVLCKit)
mediaPlayer.delegate = self
#endif
view.backgroundColor = .black
}
func prepare(in viewController: UIViewController) {
#if canImport(MobileVLCKit)
mediaPlayer.drawable = view
#endif
}
func play(request: NativePlaybackRequest) {
#if canImport(MobileVLCKit)
let media = VLCMedia(url: request.playbackURL)
var headers = ["Referer": request.referer]
if let userAgent = request.userAgent {
@ -36,14 +46,20 @@ final class VLCNativePlaybackBackend: NSObject, NativePlaybackBackend {
mediaPlayer.media = media
mediaPlayer.play()
#else
onFailure?(NativePlaybackError.backendUnavailable)
#endif
}
func stop() {
#if canImport(MobileVLCKit)
mediaPlayer.stop()
mediaPlayer.media = nil
#endif
}
}
#if canImport(MobileVLCKit)
extension VLCNativePlaybackBackend: VLCMediaPlayerDelegate {
func mediaPlayerStateChanged(_ aNotification: Notification) {
switch mediaPlayer.state {
@ -56,3 +72,4 @@ extension VLCNativePlaybackBackend: VLCMediaPlayerDelegate {
}
}
}
#endif