问题
iOS 12.2 real machine can not play the video in html5 loaded by UIWebView, link url http://community.cqliving.com/h5/info/detail/512.html?cid=512&isOpenApp=&f=10, other versions can play video
Rendering
回答1:
Is it embedded using UIWebView or WKWebView or similar?
Try setting mediaPlaybackRequiresUserAction
to YES
for the webview. I'm seeing the same issue (UIWebView
and WKWebView
both) in iOS 12.2. Works fine in iOS 12.1 and earlier.
When debugging, you see this error in safari console:
Unhandled Promise Rejection: NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission
https://developer.apple.com/documentation/uikit/uiwebview/1617954-mediaplaybackrequiresuseraction?language=objc
https://developer.apple.com/documentation/webkit/wkwebviewconfiguration/1614727-mediaplaybackrequiresuseraction?language=objc
Could be similar to this issue
Video from local storage not playing in WebView (Xamarin.Forms) after latest iOS update (12.2)
回答2:
mediaPlaybackRequiresUserAction = NO; look:https://www.jianshu.com/p/d3f326dae445
回答3:
Try including these two lines
webView.allowsInlineMediaPlayback = YES;
webView.mediaPlaybackRequiresUserAction = NO;
These lines solved my issue which is occurring in iOS 12.2
回答4:
You will need to enable insecure content loading in your app. Otherwise if you would not like to do that you can create a mirror of the video on a secure server.
https://stackoverflow.com/a/30732693 see here for more info.
来源:https://stackoverflow.com/questions/55821523/uiwebview-video-cannot-be-played-in-ios-12-2