新的 YouTube iframe 代码无法在 iPhone 上显示视频

发布于 2024-11-14 08:04:03 字数 369 浏览 8 评论 0原文

我们将新的 YouTube iframe 代码添加到我们的新闻网站中。问题是视频没有出现在 iPhone 上。

这是我的页面和代码:

<iframe width="620" height="390" src="http://www.youtube.com/v/A2V1WTF8tp4?hl=en&fs=1&autoplay=0&hd=1" frameborder="0" allowfullscreen="true"></iframe>

如何让 YouTube 视频出现在 iPhone 上?

We added the new YouTube iframe code into our News site. The problem is the video doesn't appear on the iPhone.

Here's my page and code:

<iframe width="620" height="390" src="http://www.youtube.com/v/A2V1WTF8tp4?hl=en&fs=1&autoplay=0&hd=1" frameborder="0" allowfullscreen="true"></iframe>

How can I get YouTube video to appear on the iPhone?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

雨落星ぅ辰 2024-11-21 08:04:03

视频的 URL 可能是问题所在。嵌入视频代码如下所示

<iframe class="youtube-player" type="text/html" width="640" height="385" src="http://www.youtube.com/embed/VIDEO_ID" frameborder="0">
</iframe>

请注意 URL 如何使用 embed 而不是 v

The URL for the video might be the problem. The embedded video code goes like this

<iframe class="youtube-player" type="text/html" width="640" height="385" src="http://www.youtube.com/embed/VIDEO_ID" frameborder="0">
</iframe>

Notice how the URL uses embed instead of v.

空城之時有危險 2024-11-21 08:04:03

您的问题可能是 YouTube 是基于 Flash 的,因此嵌入 iframe 无法在 iPhone 上运行,因为 iPhone 不支持 Flash。
尝试这样的事情:

<object type="application/x-shockwave-flash" data="http://www.youtube.com/v/A2V1WTF8tp4?hl=en&fs=1&autoplay=0&hd=1" width="620" height="3900">
<param name="movie" value="http://www.youtube.com/v/A2V1WTF8tp4" />
<param name="quality" value="high" />
<param name="allowFullScreen" value="true" />
<!-- Fallback content -->
<a href="http://www.youtube.com/watch?v=A2V1WTF8tp4">
<img src="http://img.youtube.com/vi/A2V1WTF8tp4/0.jpg" width="620" height="390" alt="Staff Gathers for Multicultural Springfest" />
</a>
</object>

代码礼貌: http://learningtheworld.eu/2009/youtube-embed/

Your problem may be that YouTube is Flash based, so embedding an iframe isn't going to work on the iPhone, which doesn't support Flash.
Try something like this instead:

<object type="application/x-shockwave-flash" data="http://www.youtube.com/v/A2V1WTF8tp4?hl=en&fs=1&autoplay=0&hd=1" width="620" height="3900">
<param name="movie" value="http://www.youtube.com/v/A2V1WTF8tp4" />
<param name="quality" value="high" />
<param name="allowFullScreen" value="true" />
<!-- Fallback content -->
<a href="http://www.youtube.com/watch?v=A2V1WTF8tp4">
<img src="http://img.youtube.com/vi/A2V1WTF8tp4/0.jpg" width="620" height="390" alt="Staff Gathers for Multicultural Springfest" />
</a>
</object>

code courtesy of: http://learningtheworld.eu/2009/youtube-embed/

眼前雾蒙蒙 2024-11-21 08:04:03

我有一个 UIWebView 的子类来完成此任务,这就是它的工作原理:(

在 init 中:)

NSString* url = [NSString stringWithFormat: @"http://www.youtube.com/embed/A2V1WTF8tp4"];

CGRect theFrame = CGRectMake(0, 0, 400, 300);

NSString* embedHTML = [NSString stringWithFormat: @"<iframe width=%i height=%i src=%@ frameborder=10 allowfullscreen></iframe>", theFrame.size.width, theFrame.size.height, url];

[self loadHTMLString: embedHTML baseURL: nil]; // this method is part of UIWebView.

只需确保将您的“视频视图”添加为拥有它的视图的子视图。

I have a subclass of UIWebView to accomplish this, and this is how it works:

(in init:)

NSString* url = [NSString stringWithFormat: @"http://www.youtube.com/embed/A2V1WTF8tp4"];

CGRect theFrame = CGRectMake(0, 0, 400, 300);

NSString* embedHTML = [NSString stringWithFormat: @"<iframe width=%i height=%i src=%@ frameborder=10 allowfullscreen></iframe>", theFrame.size.width, theFrame.size.height, url];

[self loadHTMLString: embedHTML baseURL: nil]; // this method is part of UIWebView.

Just ensure your "video view" is added as a subview of whichever view owns it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文