Add PiP for iOS

This commit is contained in:
Arkadiusz Fal
2022-05-20 23:23:14 +02:00
parent a93b9a2fe5
commit acf9af936a
9 changed files with 137 additions and 21 deletions

View File

@@ -1,25 +1,14 @@
import AVKit
import Defaults
import SwiftUI
struct AppleAVPlayerView: UIViewControllerRepresentable {
@EnvironmentObject<CommentsModel> private var comments
@EnvironmentObject<NavigationModel> private var navigation
struct AppleAVPlayerView: UIViewRepresentable {
@EnvironmentObject<PlayerModel> private var player
@EnvironmentObject<SubscriptionsModel> private var subscriptions
func makeUIViewController(context _: Context) -> UIViewController {
let controller = AppleAVPlayerViewController()
controller.commentsModel = comments
controller.navigationModel = navigation
controller.playerModel = player
controller.subscriptionsModel = subscriptions
player.avPlayerBackend.controller = controller
return controller
func makeUIView(context _: Context) -> some UIView {
player.playerLayerView = PlayerLayerView(frame: .zero)
return player.playerLayerView
}
func updateUIViewController(_: UIViewController, context _: Context) {
player.rebuildTVMenu()
}
func updateUIView(_: UIViewType, context _: Context) {}
}