I need to implement the VLC library in one of my TVOS applications, what I have currently is the following:
import SwiftUI
import TVVLCKit
struct VlcPlayerDemo: UIViewRepresentable{
func updateUIView(_ uiView: UIView, context: UIViewRepresentableContext<VlcPlayerDemo>) {
}
func makeUIView(context: Context) -> UIView {
return PlayerUIView(frame: .zero)
}
}
class PlayerUIView: UIView, VLCMediaPlayerDelegate {
private let mediaPlayer = VLCMediaPlayer()
override init(frame: CGRect) {
super.init(frame: frame)
let url = URL(string: "URL")!
mediaPlayer.media = VLCMedia(url: url)
mediaPlayer.delegate = self
mediaPlayer.drawable = self
mediaPlayer.play()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func layoutSubviews() {
super.layoutSubviews()
}
}
This code works and plays the content correctly, but I need to play it in full screen and have controls to pause, play and track selectors as AVPlayer has them.
all you have to do is add a ZStack layer on-top of the VLC player and add your info and interactions there,
i have a written a full working code example with TVVLCKit and SwiftUI fro Apple-Tv on github that demonstrate how to add play pause and thumbmail control, a metadata info panel (as a place holder you can fill there what ever you want)
https://github.com/shaybc/VLCTester
hope this help more