yattee/Shared/Player/AppleAVPlayerView.swift

26 lines
854 B
Swift
Raw Normal View History

2021-09-25 08:18:22 +00:00
import Defaults
2021-07-18 22:32:46 +00:00
import SwiftUI
2022-02-27 20:31:17 +00:00
struct AppleAVPlayerView: UIViewControllerRepresentable {
2021-12-04 19:35:41 +00:00
@EnvironmentObject<CommentsModel> private var comments
2021-10-28 17:14:55 +00:00
@EnvironmentObject<NavigationModel> private var navigation
@EnvironmentObject<PlayerModel> private var player
2021-12-17 20:01:05 +00:00
@EnvironmentObject<SubscriptionsModel> private var subscriptions
2021-08-23 21:31:51 +00:00
2022-02-16 20:23:11 +00:00
func makeUIViewController(context _: Context) -> UIViewController {
let controller = AppleAVPlayerViewController()
2021-08-22 19:13:33 +00:00
2021-12-04 19:35:41 +00:00
controller.commentsModel = comments
2021-10-28 17:14:55 +00:00
controller.navigationModel = navigation
controller.playerModel = player
2021-12-17 20:01:05 +00:00
controller.subscriptionsModel = subscriptions
2022-02-16 20:23:11 +00:00
player.avPlayerBackend.controller = controller
2021-07-18 22:32:46 +00:00
return controller
}
2022-02-16 20:23:11 +00:00
func updateUIViewController(_: UIViewController, context _: Context) {
2021-10-24 22:26:25 +00:00
player.rebuildTVMenu()
}
2021-07-18 22:32:46 +00:00
}