编程技术记录

世界你好!

关键属性webkit-playsinlineplaysinlineallowsInlineMediaPlayback

需要在html style里面和native 里面同时设置才有效

html video增加样式 webkit-playsinlineplaysinline

 <video controls="" height="auto" id="video1" playsinline="true" preload="auto" webkit-playsinline="true" width="100%"><source src="xxxxx.mp4" type="video/mp4">
    您的浏览器不支持 HTML5 video 标签。
 </source></video>

native code 设置allowsInlineMediaPlayback

WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init];
config.allowsInlineMediaPlayback = YES;
WKWebView *webView = [[WKWebView alloc]initWithFrame:CGRectZero configuration:config];

参考 https://www.zhihu.com/question/21094425

© Beli. All Rights Reserved.