IOS9 WKWebView html5 视频无播放按钮
IOS9 WKWebView html5 video no playback button
我正在使用 WKWebView 显示 html5 视频元素。最初加载视图时,会出现播放按钮(大圆形按钮)。如果按下它,将显示内置视频全屏控制器并开始播放视频。
在播放视频时按 "Done" 按钮:
1. 全屏控制器崩溃,我看到我的 webview
2. 但是没有播放按钮了(所以我无法再次开始播放视频)
如果您先暂停视频然后按 "Done",或者看完视频再按 "Done",一切都很好。
在 IOS8 上正常工作。
是IOS9错误,还是我配置有误?
有哪些解决方法?
这是加载到 webview 中的 html:
@"<!DOCTYPE html>
<html>
<head>
<meta name=""viewport"" content=""width=device-width, initial-scale=1, user-scalable=no"">
<style>
html, body {{
margin: 0;
padding: 0;
background-color: #000;
}}
video {{
background-color: #000;
width: 100%;
height: auto;
max-height: 100%;
margin: auto;
top: 0;
left: 0;
bottom: 0;
right: 0;
position: absolute;
}}
</style>
</head>
<body>
<video poster=""{0}""><source src=""{1}"" /></video>
</body>
</html>";
问题是缺少控件属性。
来自 Apple 文档:
The HTML5 and tags make it simple to add media to your website. Just include the <audio>
or <video>
element, use the src attribute to identify the media source, and include the controls attribute.
我正在使用 WKWebView 显示 html5 视频元素。最初加载视图时,会出现播放按钮(大圆形按钮)。如果按下它,将显示内置视频全屏控制器并开始播放视频。
在播放视频时按 "Done" 按钮:
1. 全屏控制器崩溃,我看到我的 webview
2. 但是没有播放按钮了(所以我无法再次开始播放视频)
如果您先暂停视频然后按 "Done",或者看完视频再按 "Done",一切都很好。
在 IOS8 上正常工作。
是IOS9错误,还是我配置有误? 有哪些解决方法?
这是加载到 webview 中的 html:
@"<!DOCTYPE html>
<html>
<head>
<meta name=""viewport"" content=""width=device-width, initial-scale=1, user-scalable=no"">
<style>
html, body {{
margin: 0;
padding: 0;
background-color: #000;
}}
video {{
background-color: #000;
width: 100%;
height: auto;
max-height: 100%;
margin: auto;
top: 0;
left: 0;
bottom: 0;
right: 0;
position: absolute;
}}
</style>
</head>
<body>
<video poster=""{0}""><source src=""{1}"" /></video>
</body>
</html>";
问题是缺少控件属性。
来自 Apple 文档:
The HTML5 and tags make it simple to add media to your website. Just include the
<audio>
or<video>
element, use the src attribute to identify the media source, and include the controls attribute.