Prevent videos on iOS from autoplaying in fullscreen

This commit is contained in:
Maurice Parker 2019-09-21 15:59:51 -05:00
parent 548eaac5fa
commit 2db839db98
2 changed files with 17 additions and 1 deletions

View File

@ -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()
}

View File

@ -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)
}
}