问题
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.
I was hoping to use webKitNotifications.createHTMLNotification() and embed a player inside of an HTML Notification, but the spec has since been deprecated.
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.
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.
and... that's really about it.
Advice appreciated. Thanks.
回答1:
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')});
Inside your page you can use whatever method you want to embed the YouTube player.
来源:https://stackoverflow.com/questions/18990317/showing-a-youtube-video-in-a-google-chrome-extension