I'm developing an iOS App in SwiftUI that has a link to a YouTube video. The video on YT is a Private one and I don't want anyone to be able to find the direct link, problem is, the YT controls show up on the video so you can easily just press and open the link up in Safari and therefore get the direct link.
Is there anyway in SwiftUI to prevent that so it looks like the video is just a locally resourced one please?
I've create a Swift View so I can parse other videos into it:
import SwiftUI
import WebKit
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))
}
}
And then just have this in the basic ContentView with AVKit imported:
Text("YouTube Video")
.padding()
VideoView(videoID: "U8Cd_McCdow")
.frame(minHeight: 0, maxHeight: UIScreen.main.bounds.height * 0.3)
.cornerRadius(12)
.padding(.horizontal, 24)