我在哪里设置属性" allowsInlineMediaPlayback"在NativeScript中用于WebView?
NativeScript代码
var webView = page.getViewById("webview");
webView.on(webViewModule.WebView.loadFinishedEvent, function () {});
if (page.ios){
webView.ios.scrollView.bounces = false;
webView.ios.scrollView.showsHorizontalScrollIndicator = false;
webView.ios.scrollView.showsVerticalScrollIndicator = false;
webView.ios.backgroundColor = UIColor.clearColor;
webView.ios.opaque = false;
webView.ios.allowsInlineMediaPlayback = true;
webView.ios.mediaPlaybackRequiresUserAction = false;
}
webView.src = "xx";
Xcode的工作示例:
func loadWebSite() {
let theConfiguration:WKWebViewConfiguration? = WKWebViewConfiguration()
let thisPref:WKPreferences = WKPreferences()
theConfiguration!.allowsInlineMediaPlayback = true
theConfiguration!.mediaPlaybackRequiresUserAction = false
self.wkWebView = WKWebView(frame: self.getFrame(), configuration: theConfiguration!)