Prevent videos on iOS from autoplaying in fullscreen
This commit is contained in:
parent
548eaac5fa
commit
2db839db98
|
@ -28,6 +28,12 @@ function linkHover() {
|
|||
}
|
||||
}
|
||||
|
||||
function inlineVideos() {
|
||||
document.querySelectorAll("video").forEach(element => {
|
||||
element.setAttribute("playsinline", true)
|
||||
});
|
||||
}
|
||||
|
||||
function error() {
|
||||
document.body.innerHTML = "error";
|
||||
}
|
||||
|
@ -40,4 +46,5 @@ function render(data) {
|
|||
wrapFrames()
|
||||
stripStyles()
|
||||
linkHover()
|
||||
inlineVideos()
|
||||
}
|
||||
|
|
|
@ -63,7 +63,16 @@ class DetailViewControllerWebViewProvider: NSObject, WKNavigationDelegate {
|
|||
|
||||
private func replenishQueueIfNeeded() {
|
||||
while queue.count < minimumQueueDepth {
|
||||
let webView = WKWebView(frame: .zero)
|
||||
let preferences = WKPreferences()
|
||||
preferences.javaScriptCanOpenWindowsAutomatically = false
|
||||
preferences.javaScriptEnabled = true
|
||||
|
||||
let configuration = WKWebViewConfiguration()
|
||||
configuration.preferences = preferences
|
||||
configuration.allowsInlineMediaPlayback = true
|
||||
configuration.mediaTypesRequiringUserActionForPlayback = .video
|
||||
|
||||
let webView = WKWebView(frame: .zero, configuration: configuration)
|
||||
enqueueWebView(webView)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue