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

22,380

Solution 1

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.

Solution 2

allowsInlineMediaPlayback UIWebView properties

Boolean value that determines whether HTML5 videos play inline or use the native full-screen controller. (developer.apple.com)

You can use this feature on iPad. On the iPhone there is no such function. If you try play video with uiwebview on iPhone it will be played in full screen mode.

Share:
22,380
Fastas
Author by

Fastas

Updated on May 27, 2020

Comments

  • Fastas
    Fastas about 4 years

    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.