yattee/Apple TV/PlayerView.swift
2021-06-28 12:43:07 +02:00

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!)
}
}