Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 inline video on iPhone vs iPad/Browser

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

like image 540
Andre Avatar asked Sep 13 '10 10:09

Andre


People also ask

Does HTML5 work on iPhone?

iOS 5 also performed well in terms of HTML5 compatibility compared to desktop browsers, running slightly behind Mozilla's Firefox 7.1 and just ahead of Apple's desktop Safari 5.1.

Does Safari support HTML5 iPhone?

Safari supports HTML5. If YouTube video doesn't play, try either disabling or uninstalling extensions like ClickToFlash.

Does Safari support HTML5 video?

Safari supports the <video> and <audio> media elements on iOS 3.0 and later and in Safari 3.1 and later on the desktop (Mac OS X and Windows). Support for these media elements allows Safari and other HTML5-compliant browsers to play the indicated source media without using a plug-in.

How do I enable HTML5 in Safari on iPad?

If you turn on the Develop menu in Safari (Preferences » Advanced » check the box), you get the option to choose the User Agent string Safari will hand to a site to tell what browser it is. From the Develop menu, Choose User Agent » Mobile Safari 3.2. 2 - iPad and the site will switch to HTML5 if it supports it.


1 Answers

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".

like image 145
Andre Avatar answered Oct 05 '22 22:10

Andre