Ниже приведен код, который у меня сейчас есть. Как включить встроенное воспроизведение мультимедиа для swiftUI? Я хочу, чтобы видео автоматически воспроизводилось при появлении веб-просмотра. Ниже приведен код, который у меня есть. Заранее спасибо.
Button(action: {
self.isPlayed.toggle()//toggles the boolean isPlayed
self.appear.toggle()//toggles the boolean appear
}, label: {
//if the boolean of isPlayed and
if isPlayed && appear{
Image(systemName: "pause")
.font(Font.system(size: 30))
} else{
Image(systemName:"play")
.font(Font.system(size: 30))
}
})
Spacer()
}
if appear == true{
WebView(request: URLRequest(url: URL(string: "http:www.\(websites[counter])?playsinline=1")!))
.frame(width:300, height:300)
.padding()
.opacity(1)
}
}
}
}
struct WebView: UIViewRepresentable {
let request: URLRequest//pass the website to webkit
func makeUIView(context: Context) -> WKWebView {
return WKWebView()
}
func updateUIView(_ uiView: WKWebView, context: Context) {
uiView.load(request)
}
}