Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embed video from youtube.com into iphone app

Tags:

youtube

iphone

i'm trying to embed youtube video into my iphone application. I'm using UIWebView and loading embed code from youtube as html string. So i have a layout with basic html markup and i'm placing there this code.

<embed id="yt" src="http://www.youtube.com/watch?v=L9szn1QQfas&fs=0" type="application/x-shockwave-flash" width="%width%" height="%height%"></embed>

The problem is the video always opens in the fullscreen mode. I've changed my webview property allowsInlineMediaPlayback to YES _webview.allowsInlineMediaPlayback = YES; but it doesn't works too. Is there a way to play videos from youtube without fullscreen?

I'm also tried to embed like this

<iframe title="YouTube video player" id="videoframe" width="%width%" height="%height%" src="http://www.youtube.com/embed/L9szn1QQfas?rel=0" frameborder="0"></iframe>

and this

<object type="application/x-shockwave-flash" data="http://www.youtube.com/v/L9szn1QQfas" width="%width%" height="%height%">
<param name="movie" value="http://www.youtube.com/v/L9szn1QQfas" />
<param name="quality" value="high" />
<param name="allowFullScreen" value="false" />
<embed id="yt" src="http://www.youtube.com/v/L9szn1QQfas" type="application/x-shockwave-flash" width="%width%" height="%height%"></embed>
</object>

Thanks.

like image 827
Nikolay Osaulenko Avatar asked Feb 28 '11 16:02

Nikolay Osaulenko


1 Answers

As far as I'm aware, inline media playback is only supported on iPad, not iPhone. This would be due to size limitations with the screens.

Edit:

I setup a test project, with a UIWebView and the code:

[webView setAllowsInlineMediaPlayback:YES];
[webView loadHTMLString:@"<embed id=\"yt\" src=\"http://www.youtube.com/watch?v=L9szn1QQfas&fs=0\" type=\"application/x-shockwave-flash\" width=\"300\" height=\"300\"></embed>"
                    baseURL:nil];

I ran the same exact code on both an iPhone and an iPad, both running iOS 4.2.1.

The results were that the iPhone would only play the video in fullscreen mode, regardless of setting the inline media playback to YES and the iPad played the video inline. Here's a picture:

enter image description here

like image 89
Jasarien Avatar answered Oct 10 '22 01:10

Jasarien