mirror of
https://github.com/yattee/yattee.git
synced 2024-12-14 22:30:32 +05:30
34 lines
648 B
Swift
34 lines
648 B
Swift
import AVKit
|
|
import Foundation
|
|
import Siesta
|
|
import SwiftUI
|
|
|
|
struct PlayerView: View {
|
|
@ObservedObject private var store = Store<Video>()
|
|
|
|
let resource: Resource
|
|
|
|
init(id: String) {
|
|
resource = InvidiousAPI.shared.video(id)
|
|
resource.addObserver(store)
|
|
}
|
|
|
|
var body: some View {
|
|
VStack {
|
|
pvc?
|
|
.edgesIgnoringSafeArea(.all)
|
|
}
|
|
.onAppear {
|
|
resource.loadIfNeeded()
|
|
}
|
|
}
|
|
|
|
var pvc: PlayerViewController? {
|
|
guard store.item != nil else {
|
|
return nil
|
|
}
|
|
|
|
return PlayerViewController(video: store.item!)
|
|
}
|
|
}
|