Iām converting an app that is largely based on webviews to WKWebView
. At first, I was prevented from accessing the accelerometer because of CORS cross domain policy issues. When I solved that, the video that would play without a problem, now no longer plays.
How do I get enable both video playback and access to the accelerometer?
Basically if I add this line in the snippet blow:
configuration.preferences.setValue(true, forKey: "allowFileAccessFromFileURLs")
then the accelerometer works, video doesn't. Remove this line, the video plays but instead of the accelerometer enabled screen, an error is displayed.
let webView: WKWebView = {
let configuration = WKWebViewConfiguration()
configuration.mediaTypesRequiringUserActionForPlayback = []
configuration.allowsInlineMediaPlayback = true
configuration.preferences.setValue(true, forKey: "allowFileAccessFromFileURLs")
return WKWebView(frame: .zero, configuration: configuration)
}()
They were working together with the UIWebview, but with my changes to WKWebView I can't get them to work both together.