HTML5 inline video on iPhone vs iPad/Browser

IphoneIpadVideoHtml

Iphone Problem Overview


I've created an HTML5 video player (very simple) that works perfectly on the iPad and the browser.

However, when I open it on the iPhone, I only get a play button which, when pressed, opens the native video player on a new window, on top of all my stuff.

That means I lose access to my custom controls and time tracking (written in Javascript), since the video is now running isolated.

Is there any way to override Apple's control of HTML5 video on the iphone and get it working like on the ipad?

Cheers

Iphone Solutions


Solution 1 - Iphone

Right,

I was going nowhere with this and filed a bug with Apple.

After a couple of weeks they got back to me saying, very simply, that I should add "webkit-playsinline" to the video tag on the HTML, as well as adding the "allowsInlineMediaPlayback" property on the UIWebView.

So in the end, this is what it looks like:

HTML

<video id="player" width="480" height="320" webkit-playsinline>

Obj-C

webview.allowsInlineMediaPlayback = YES;

And all works just fine :)

Hope this helps someone, as it's virtually undocumented and the only place I could find a reference to "webkit-playsinline" was in the iAds reference, where it says: "iAds JS only".

Solution 2 - Iphone

Until iOS Safari implements inline video support, you need to write video decoder in a web supported language. There are existing implementations of video decoders, such as Broadway for H.264 (video), jsmpeg for mpeg1, and ogv.js (video and sound support).

Keep in mind that the process of decoding a video is computationally heavy. Expect a relatively slow FPS (±20).

For your reference, these guys have prepared a demo of a video that you can play on your iOS device.

Solution 3 - Iphone

In iOS 10+

Apple enabled the attribute playsinline in all browsers on iOS 10, so this works seamlessly:

<video src="file.mp4" playsinline>

In iOS 8 and iOS 9

You can work around this issue by simulating the playback by skimming the video instead of actually .play()'ing it.

You can use iphone-inline-video to take care of the playback and audio sync (if any), and it keeps the <video> working as it should.

Solution 4 - Iphone

Do you have an app created or is this for mobile safari? If you have an app and use UIWebView you should set UIWebView's allowsInlineMediaPlayback property..

Solution 5 - Iphone

In iOS 10 adding 'playsinline' attribute to the HTML5 video tag did not prevent fullscreen playback on an iPhone UIWebview until I also added the 'controls' attribute. This is how I got it working:

<video width="100%" height="240" controls playsinline>
      <source src="movie.mp4" type="video/mp4" >
</video>

With, of course, _webView.allowsInlineMediaPlayback=YES; in the ViewController also.

Solution 6 - Iphone

There are some work arounds, I'm working on a library to allow this functionality automatically. However, until Apple sets safari to

webview.allowsInlineMediaPlayback = YES;

then we will have to use hacks for the same behavior.

You can check out the project here: https://github.com/newshorts/InlineVideo to see if it meets your needs.

Solution 7 - Iphone

Just add following to your config.xml: <preference name="AllowInlineMediaPlayback" value="true" /> Otherwise UIWebView will neglect the webkit-playsinline attribute.

Solution 8 - Iphone

You can easily allow this by adding this to your config.xml: The UIWebView should then respect the webkit-playsinline attribute.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAndreView Question on Stackoverflow
Solution 1 - IphoneAndreView Answer on Stackoverflow
Solution 2 - IphoneGajusView Answer on Stackoverflow
Solution 3 - IphonefreganteView Answer on Stackoverflow
Solution 4 - IphoneLarsJKView Answer on Stackoverflow
Solution 5 - IphonesaswanbView Answer on Stackoverflow
Solution 6 - IphonenewshortsView Answer on Stackoverflow
Solution 7 - IphoneParadiseView Answer on Stackoverflow
Solution 8 - IphoneParadiseView Answer on Stackoverflow