2 years ago
#43380
Henny C
Swift UI - Embed Video Unavailable
I am still fairly new with using SwiftUI. I am creating my first app and I was trying to embed a youtube video into my app, but I keep running into this problem where the video is automatically unavailable for whatever reason. Here is my code down below. Im not totally sure what I did wrong.
struct VideoView: UIViewRepresentable{
let videoID: String
func makeUIView(context: Context) -> WKWebView {
return WKWebView()
}
func updateUIView(_ uiView: WKWebView, context: Context) {
guard let youtubeURL = URL (string: "https://www.youtube.com/embed/\(videoID)")
else {
return
}
uiView.scrollView.isScrollEnabled = false
uiView.load(URLRequest(url: youtubeURL))
}
}
Some Pictures down below:
swift
swiftui
embed
0 Answers
Your Answer