上播放的PhoneGap YouTube视频视频、PhoneGap、YouTube

由网友(巴黎彼岸破碎)分享简介:我正在开发使用PhoneGap的其中一个视频部分显示YouTube视频使用YouTube jsonc API检索列表中的应用程序。我希望视频能够在应用程序内发挥其链接被点击的时候,这样当视频被关闭,我的应用程序界面再次显示。的Youtube API为RSTP://和http://链接的视频,但我一直没能播放视频的应用程...

我正在开发使用PhoneGap的其中一个视频部分显示YouTube视频使用YouTube jsonc API检索列表中的应用程序。我希望视频能够在应用程序内发挥其链接被点击的时候,这样当视频被关闭,我的应用程序界面再次显示。的Youtube API为RSTP://和http://链接的视频,但我一直没能播放视频的应用程序中。一旦这样的作品,我想将它移植过来黑莓等设备也一样,所以PhoneGap的具体解决方案是非常preferred。

I am developing an application using phonegap in which a video section shows list of youtube videos retrieved using youtube jsonc api. I would like the video to be played inside the application when its link is clicked, so that when the video is closed, my application interface is shown again. Youtube apis give rstp:// and http:// links for the videos, but I haven't been able to play the videos inside the application. Once that works, I would like to port it over to blackberry and other devices too, so a phonegap specific solution is highly preferred.

推荐答案

在我们已经制作,为iPhone客户端项目,我们不得不采取的YouTube链接,并通过改变它的 <嵌入> 标记。下面是它是如何做:

On a client project that we've worked on, for iPhone, we had to take the YouTube link and change it over to an <embed> tag. Here is how it's done:

function getYouTubeLink(url) {
  var isYouTube = RegExp(/.youtube.com.+v=([w_-]+)/i);
  var r = isYouTube.exec(url);
  if (r && r[1]) {
    var video = 'http://www.youtube.com/v/' + url + '&hl=en&fs=1&';
    var youtube =  '<embed src="' + video + '" type="application/x-shockwave-flash"' + 
      ' allowscriptaccess="always"' + 
      ' allowfullscreen="true" width="90" height="60"></embed>';
    return youtube;
  }
}

iOS的PhoneGap的处理这个pretty的好。对于Android,只要打开了一个http:// YouTube链接应该够了Android OS能够识别它,并转移用户对本地的YouTube应用程序

iOS PhoneGap handles this pretty well. For Android, simply opening up an http:// YouTube link should be enough for the Android OS to recognize it and divert the user to the native YouTube application.

有关黑莓... O哎呀,我不知道。有个声音告诉我,它会无法正常使用。原谅我,我是一个疲惫的黑莓开发者承载了太多的黑莓引起的疤痕。

For BlackBerry... o geez, I don't know. Something tells me it wouldn't work too well. Forgive me, I am a jaded BlackBerry developer bearing too many BlackBerry-induced scars.

祝你好运!

阅读全文

相关推荐

最新文章