2021-06-11 04:20:10 +05:30
|
|
|
import AVKit
|
|
|
|
import Foundation
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct PlayerView: View {
|
2021-06-11 05:35:59 +05:30
|
|
|
@ObservedObject private var provider: VideoDetailsProvider
|
|
|
|
|
|
|
|
init(id: String) {
|
|
|
|
provider = VideoDetailsProvider(id)
|
|
|
|
}
|
2021-06-11 04:20:10 +05:30
|
|
|
|
|
|
|
var body: some View {
|
2021-06-17 00:42:41 +05:30
|
|
|
VStack {
|
|
|
|
pvc?
|
|
|
|
.edgesIgnoringSafeArea(.all)
|
2021-06-11 04:20:10 +05:30
|
|
|
}
|
|
|
|
.task {
|
2021-06-25 04:18:28 +05:30
|
|
|
Task {
|
2021-06-11 04:20:10 +05:30
|
|
|
provider.load()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-06-17 00:42:41 +05:30
|
|
|
|
|
|
|
var pvc: PlayerViewController? {
|
|
|
|
guard provider.video != nil else {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return PlayerViewController(video: provider.video!)
|
|
|
|
}
|
2021-06-11 04:20:10 +05:30
|
|
|
}
|