1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-15 23:00:32 +05:30
yattee/Apple TV/PlayerView.swift

34 lines
648 B
Swift
Raw Normal View History

2021-06-11 04:20:10 +05:30
import AVKit
import Foundation
2021-06-28 16:13:07 +05:30
import Siesta
2021-06-11 04:20:10 +05:30
import SwiftUI
struct PlayerView: View {
2021-06-28 16:13:07 +05:30
@ObservedObject private var store = Store<Video>()
let resource: Resource
2021-06-11 05:35:59 +05:30
init(id: String) {
2021-06-28 16:13:07 +05:30
resource = InvidiousAPI.shared.video(id)
resource.addObserver(store)
2021-06-11 05:35:59 +05:30
}
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
}
2021-06-28 16:13:07 +05:30
.onAppear {
resource.loadIfNeeded()
2021-06-11 04:20:10 +05:30
}
}
2021-06-17 00:42:41 +05:30
var pvc: PlayerViewController? {
2021-06-28 16:13:07 +05:30
guard store.item != nil else {
2021-06-17 00:42:41 +05:30
return nil
}
2021-06-28 16:13:07 +05:30
return PlayerViewController(video: store.item!)
2021-06-17 00:42:41 +05:30
}
2021-06-11 04:20:10 +05:30
}