Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

uiwebview Video cannot be played in IOS 12.2

Tags:

ios

uiwebview

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

like image 554
gkh Avatar asked Apr 24 '19 02:04

gkh


3 Answers

Try including these two lines

webView.allowsInlineMediaPlayback = YES;
webView.mediaPlaybackRequiresUserAction = NO;

These lines solved my issue which is occurring in iOS 12.2

like image 143
Sateesh Pasala Avatar answered Oct 17 '22 18:10

Sateesh Pasala


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)

like image 2
1800 INFORMATION Avatar answered Oct 17 '22 19:10

1800 INFORMATION


mediaPlaybackRequiresUserAction = NO; look:https://www.jianshu.com/p/d3f326dae445

like image 2
Jayxiang Avatar answered Oct 17 '22 19:10

Jayxiang