在Google Chrome扩展程序中显示YouTube视频

在Google Chrome扩展程序中显示YouTube视频

问题描述:

我想将YouTube播放器嵌入到页面上并显示给用户.如果使用前景弹出式窗口托管播放器,则当弹出式窗口失去焦点时,由于会删除整个弹出式窗口,因此会破坏播放器.

I would like to embed a YouTube player onto a page and show it to a user. If a foreground popup is used to host the player then, when the popup loses focus, the player is destroyed because the entire popup is removed.

我希望使用webKitNotifications.createHTMLNotification()并将播放器嵌入HTML通知中,但此规范已被弃用.

I was hoping to use webKitNotifications.createHTMLNotification() and embed a player inside of an HTML Notification, but the spec has since been deprecated.

只是好奇是否有人对如何实现这一目标有任何高明的想法?我怀疑在后台页面上托管YouTube播放器违反了YouTube的服务条款.

Just curious if anyone has any really crafty ideas on how to achieve this? I suspect hosting the YouTube player on a background page is a violation of YouTube's Terms of Service.

浏览开发者.通道API:

Looking through the dev. channel APIs:

  • http://developer.chrome.com/extensions/notifications.html - Too restrictive compared to HTML Notification. Doesn't look like I can embed a YouTube player inside one of these guys.

而且...就是这样.

建议表示赞赏.谢谢.

您可以在页面扩展名中简单地添加一个HTML文件,例如video.html,在清单中的web_accesible_resources下列出该文件,然后进行显示使用:

You can simply have an HTML file in your extension for your page, for instance video.html, list it in your manifest under web_accesible_resources, and show it using:

chrome.tabs.create({url: chrome.extension.getURL('video.html')});

在页面内部,您可以使用任何想要嵌入YouTube播放器的方法.

Inside your page you can use whatever method you want to embed the YouTube player.