1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-13 13:50:32 +05:30
yattee/Shared/Player/AppleAVPlayerView.swift

46 lines
1.6 KiB
Swift
Raw Normal View History

2022-05-21 02:53:14 +05:30
import AVKit
2021-09-25 13:48:22 +05:30
import Defaults
2021-07-19 04:02:46 +05:30
import SwiftUI
2022-08-21 02:35:40 +05:30
#if os(iOS)
struct AppleAVPlayerView: UIViewRepresentable {
@EnvironmentObject<PlayerModel> private var player
2021-08-24 03:01:51 +05:30
2022-08-21 02:35:40 +05:30
func makeUIView(context _: Context) -> some UIView {
let playerLayerView = PlayerLayerView(frame: .zero)
playerLayerView.player = player
return playerLayerView
}
func updateUIView(_: UIViewType, context _: Context) {}
2021-07-19 04:02:46 +05:30
}
2022-08-21 02:35:40 +05:30
#else
struct AppleAVPlayerView: UIViewControllerRepresentable {
@EnvironmentObject<AccountsModel> private var accounts
@EnvironmentObject<CommentsModel> private var comments
@EnvironmentObject<NavigationModel> private var navigation
@EnvironmentObject<PlayerModel> private var player
@EnvironmentObject<PlaylistsModel> private var playlists
@EnvironmentObject<SubscriptionsModel> private var subscriptions
func makeUIViewController(context _: Context) -> AppleAVPlayerViewController {
let controller = AppleAVPlayerViewController()
controller.accountsModel = accounts
controller.commentsModel = comments
controller.navigationModel = navigation
controller.playerModel = player
controller.playlistsModel = playlists
controller.subscriptionsModel = subscriptions
2021-07-19 04:02:46 +05:30
2022-08-21 02:35:40 +05:30
player.avPlayerBackend.controller = controller
return controller
}
func updateUIViewController(_: AppleAVPlayerViewController, context _: Context) {
player.rebuildTVMenu()
}
}
#endif