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 {
|
2021-06-23 22:19:58 +00:00
|
|
|
Task.init {
|
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
|
|
|
}
|