yattee/Apple TV/PlayerView.swift

32 lines
606 B
Swift
Raw Normal View History

2021-06-10 22:50:10 +00:00
import AVKit
import Foundation
import SwiftUI
struct PlayerView: View {
2021-06-11 00:05:59 +00:00
@ObservedObject private var provider: VideoDetailsProvider
init(id: String) {
provider = VideoDetailsProvider(id)
}
2021-06-10 22:50:10 +00:00
var body: some View {
2021-06-16 19:12:41 +00:00
VStack {
pvc?
.edgesIgnoringSafeArea(.all)
2021-06-10 22:50:10 +00:00
}
.task {
Task {
2021-06-10 22:50:10 +00:00
provider.load()
}
}
}
2021-06-16 19:12:41 +00:00
var pvc: PlayerViewController? {
guard provider.video != nil else {
return nil
}
return PlayerViewController(video: provider.video!)
}
2021-06-10 22:50:10 +00:00
}