Yauheni Aliashkevich Yauheni Aliashkevich - 1 month ago 28
iOS Question

IOS9 WKWebView html5 video no playback button

I'm using WKWebView to display html5 video element. When view is loaded initially there is play button (big round button). If you press it built-in video fullscreen controller is displayed and video starts playing.

While video is playing press "Done" button:

1. fullscreen controller collapses and I see my webview

2. but there is no play button anymore (so I can't start playing video again)

If you first pause video and that press "Done", or watch video to the end and then press "Done" everything is fine.

Works on IOS8 without issues.

Is it IOS9 bug, or I have something configured wrong?
What workarounds are possible?

Here is html that is loaded into webview:

@"<!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>";

Answer

The problem was missed controls attribute.

From Apple documentation:

The HTML5 and tags make it simple to add media to your website. Just include the or element, use the src attribute to identify the media source, and include the controls attribute.

https://developer.apple.com/library/content/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/Introduction/Introduction.html

Comments