Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I play a youtube video in a UIWebView inline (not fullscreen)?

I have looked everywhere on how to do this and haven't found an answer yet. Is it possible to play a youtube video in a UIWebView on an iPhone inline, i.e. not fullscreen? I know that the iPhone doesn't support flash, but youtube supports html5 and has h.264 videos doesn't it? shouldn't I be able to do this then?

I have set allowsInlineMediaPlayback to YES, but still it plays fullscreen.

like image 749
Fastas Avatar asked Jul 15 '11 16:07

Fastas


1 Answers

Yes you can, you need to set property on UIWebView

 webView.allowsInlineMediaPlayback=YES;

And you need to add &playsinline=1 to YouTube iframe embedding code.

 <iframe webkit-playsinline width="200" height="200" src="https://www.youtube.com/embed/GOiIxqcbzyM?feature=player_detailpage&playsinline=1" frameborder="0"></iframe>

Tested on iPhone 4S running iOS 6.1.2 works like a charm.

like image 192
stringCode Avatar answered Oct 21 '22 15:10

stringCode