iPhone 上的 YouTube 视频 PhoneGap 应用程序

发布于 2024-12-07 07:26:59 字数 1062 浏览 4 评论 0原文

很抱歉再次回到这个话题,但我真的很沮丧!我阅读了我找到的所有资源,在网上搜索,但我无法对我的问题提出明确的答案。

问题描述
我正在使用phonegap 1.0 创建一个iphone 应用程序。在此应用程序中,一个选项卡专门用于来自我的 YouTube 频道的 RSS 提要,我希望我的用户能够在单击特定条目后播放这些视频。 问: 有可能吗?最好的解决方案是在应用程序内播放视频,但显示缩略图并将用户重定向到本机 youtube 应用程序也是可以接受的(即使在这种情况下,我希望当 youtube 完成播放视频时将控件返回到原始应用程序) )。

尝试过的解决方案
在网上搜索我找到了几种解决方案,人们说这些解决方案对他们有用,但没有一个对我有用!

  • 使用“object”标签,我最终会看到白屏

    <对象 id="video" width="296" height="100%" data="http://www.youtube.com/v/gDjb9RVMF4c" type="application/x-shockwave -闪光”>
        <参数名称=“allowfullscreen”值=“true”/>
        
    
    
  • 使用“embed”标签,我最终得到一个白屏

    
    
  • 我也尝试了“视频”标签,但据我了解,这仍然是不可能的。

    >

如果我错过了已经写在某处的解决方案,我真的很抱歉,但是相信我......我在提问之前做了功课:-) 谢谢!!

I'm sorry to come back to this topic again, but i'm really frustrated!! I've read every resource i've found, googling around the web, but i couldn't come up with a definitive answer to my problem.

Problem description
I'm creating an iphone app with phonegap 1.0. In this app, one tab is dedicated to a rss feed from my youtube channel and i want my users to be able to play these videos, after clicking on a specific entry.
Question: is it possible? best solution would be to play the video inside the app, but displaying a thumbnail image and redirecting the user to native youtube app is also acceptable (even though in this case i want the control back to the original app when youtube finishes to play the video).

Tried solutions
Searching on the web I found several solutions and people say that these solutions work for them, but none of them work for me!

  • use an "object" tag, i end up with a white screen

    <object id="video" width="296" height="100%" data="http://www.youtube.com/v/gDjb9RVMF4c" type="application/x-shockwave-flash">
        <param name="allowfullscreen" value="true" />
        <param name="src" value="http://www.youtube.com/v/gDjb9RVMF4c" />
    </object>
    
  • using an "embed" tag, i end up with a white screen

    <embed src="http://www.youtube.com/v/gDjb9RVMF4c" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="280" height="100%"></embed>
    
  • i also tried a "video" tag, but as far as i understood, this is still not possible.

I'm really sorry if i missed a solution already written somewhere, but trust me ... i did my homework before askying :-)
Thx!!

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

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

发布评论

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

评论(4

尬尬 2024-12-14 07:26:59

这是一个很好的教程,拯救了我的一天

http://eisabainyo.net/weblog/2012/01/24/embed-a-youtube-video-iframe-in-phonegap-app/

另外我发布了一些代码以供快速访问。

<html>
    <head>
        <title>YouTube video</title>
        <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
        <meta name="apple-mobile-web-app-capable" content="yes" />
        <meta name="apple-mobile-web-app-status-bar-style" content="black" />
        <script src="phonegap-1.2.0.js"></script>
    </head>
    <body>

        <iframe width="560" height="315" src="http://www.youtube.com/embed/9HDeEbJyNK8" frameborder="0" allowfullscreen></iframe>

    </body>
</html>

然后在 Phonegap.plist 中进行以下更改,

MediaPlaybackRequiresUserAction: NO
AllowInlineMediaPlayback: YES
OpenAllWhitelistURLsInWebView: YES
ExternalHosts
          *.youtube.com
          *.ytimg.com

视频也将在您的模拟器上播放。

Here is a nice tutorial Which Saved my Day

http://eisabainyo.net/weblog/2012/01/24/embed-a-youtube-video-iframe-in-phonegap-app/

Also i m posting some codes For a quick Access.

<html>
    <head>
        <title>YouTube video</title>
        <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
        <meta name="apple-mobile-web-app-capable" content="yes" />
        <meta name="apple-mobile-web-app-status-bar-style" content="black" />
        <script src="phonegap-1.2.0.js"></script>
    </head>
    <body>

        <iframe width="560" height="315" src="http://www.youtube.com/embed/9HDeEbJyNK8" frameborder="0" allowfullscreen></iframe>

    </body>
</html>

Then make the following changes in Phonegap.plist

MediaPlaybackRequiresUserAction: NO
AllowInlineMediaPlayback: YES
OpenAllWhitelistURLsInWebView: YES
ExternalHosts
          *.youtube.com
          *.ytimg.com

Video will play on your Simulator Also.

节枝 2024-12-14 07:26:59

除了使用 您还需要在 PhoneGap.plist 中将属性 OpenAllWhitelistURLsInWebView 设置为 YES。这将在 PhoneGap 应用程序本身内显示和播放视频。它是经过尝试和测试的。

Apart from using <iframe> ... </iframe> you also need to set the property OpenAllWhitelistURLsInWebView to YES in your PhoneGap.plist. This would show and play the video inside the PhoneGap application itself. It is tried and tested.

时光沙漏 2024-12-14 07:26:59

您可以尝试将 YouTube 视频嵌入为 iframe,我相信这是现在推荐的方法:

http://apiblog.youtube.com/2010/07/new-way-to-embed-youtube-videos.html

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

You could try embedding the YouTube video as an iframe, I believe that is the recommended way to do it now:

http://apiblog.youtube.com/2010/07/new-way-to-embed-youtube-videos.html

<iframe src="http://www.youtube.com/embed/VIDEO_ID" class="youtube-player" type="text/html" width="640" height="385"  frameborder="0">
</iframe>
靑春怀旧 2024-12-14 07:26:59

这是我最终在我的应用程序中使用的组件 。借助 YouTube iFrame API 完成。

Here is a component I've end up using in my app. Done with a help of YouTube iFrame API.

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