在NativeScript中为WebView设置allowInlineMediaPlayback

时间:2018-04-18 11:35:15

标签: ios webview nativescript

我在哪里设置属性" 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!)

1 个答案:

答案 0 :(得分:0)

此问题的解决方案发布在github