Not sure how to setup bindings from the init function.
struct VideoPlayerView: View {
let url: URL
@State private var videoPos: Double = 0
@State private var videoDuration: Double = 0
@State private var seeking = false
private var videoView: VideoView
init(url: URL) {
self.url = url
self.videoView = VideoView(
url: self.url,
videoPos: $videoPos,
videoDuration: $videoDuration,
seeking: $seeking
)
}
func togglePlay () {
self.videoView.play()
}
var body: some View {
ZStack {
videoView
Button(action: togglePlay) {
Text("Test")
}
}
}
}
I'm getting the following error on the 3 lines with the '$'.
Variable 'self.videoView' used before being initialized