1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-15 23:00:32 +05:30
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!)
}
}