Android

版本大于4.4,需要将自动播放权限打开

参考代码:

WebView.getSettings().setMediaPlaybackRequiresUserGesture(false)

参考链接:

https://developer.android.com/reference/android/webkit/WebSettings.html#setMediaPlaybackRequiresUserGesture(boolean)

iOS

iOS需要使用WKWebVeiw,并且需要允许非全屏播放,并将自动播放权限打开

参考代码:

webView.configuration.allowsInlineMediaPlayback = YES;

webView.configuration.requiresUserActionForMediaPlayback = NO;

参考链接:

https://developer.apple.com/documentation/webkit/wkwebviewconfiguration?language=objc

results matching ""

    No results matching ""