iphone phonegap 应用程序上的 YouTube 视频 [英] youtube videos on iphone phonegap app

查看:22
本文介绍了iphone phonegap 应用程序上的 YouTube 视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

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

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

    推荐答案

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

    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>
    

    然后在Phonegap.plist中做如下修改

    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.

    这篇关于iphone phonegap 应用程序上的 YouTube 视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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