将youtube.com的视频嵌入到iphone应用中 [英] Embed video from youtube.com into iphone app

查看:170
本文介绍了将youtube.com的视频嵌入到iphone应用中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将YouTube视频嵌入到我的iphone应用程序中。我正在使用UIWebView并从youtube加载嵌入代码作为html字符串。所以我有一个带有基本html标记的布局,我将这个代码放在那里。

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>

问题是视频总是以全屏模式打开。我已将我的webview属性allowInlineMediaPlayback更改为YES _webview.allowsInlineMediaPlayback = YES; 但它也不起作用。有没有办法在没有全屏的情况下播放来自youtube的视频?

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?

我也试图像这样嵌入

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

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

谢谢。

推荐答案

据我所知,内联媒体播放仅支持iPad,而不支持iPhone。这可能是由于屏幕尺寸限制造成的。

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.

编辑:

我设置了一个测试项目,一个 UIWebView 和代码:

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];

我在iPhone和iPad上都运行了相同的代码,两者都运行iOS 4.2.1。

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

结果是iPhone只能以全屏模式播放视频,无论将内嵌媒体播放设置为 YES 并且iPad播放了视频内联。这是一张图片:

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:

这篇关于将youtube.com的视频嵌入到iphone应用中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆