|
| 1 | +Video5 |
| 2 | +====== |
| 3 | + |
| 4 | +Extension for Google Chrome to replace video providers embedded Flash players with |
| 5 | +standard HTML5 video tags. |
| 6 | + |
| 7 | + |
| 8 | +Supported |
| 9 | +--------- |
| 10 | + |
| 11 | +* Youtube |
| 12 | + |
| 13 | + Youtube.com pages are not modified. You should try `Youtube HTML5 Beta |
| 14 | + <http://www.youtube.com/html5>`_. Youtube videos embedded on other web pages |
| 15 | + are supported. |
| 16 | + |
| 17 | +* Vimeo |
| 18 | + |
| 19 | + Vimeo.com pages are not modified. You should try `Vimeo HTML5 Beta |
| 20 | + <http://vimeo.com/blog:268>`_ (click on the "Switch to HTML5 Player" link |
| 21 | + below any video). Vimeo videos embedded on other web pages are supported. |
| 22 | + |
| 23 | + |
| 24 | +Extending |
| 25 | +--------- |
| 26 | + |
| 27 | +To add support for a new video player provider, |
| 28 | + |
| 29 | +1. Create a new .js file inside the handlers subdirectory, modeled after |
| 30 | + youtube.js or any other file in that directory. Specifically, say you are |
| 31 | + supporting "FooVideo" in foo.js:: |
| 32 | + |
| 33 | + // Your file MUST be wrapped in a function, and you MUST return your |
| 34 | + // handler object at the end of your function. |
| 35 | + (function() { |
| 36 | + |
| 37 | + // The constructor is passed the DOM object for the Flash plugin, the url |
| 38 | + // of the player. |
| 39 | + FooVideo = function(domObject, url) { |
| 40 | + this.domObject = domObject; |
| 41 | + this.url = url; |
| 42 | + }; |
| 43 | + |
| 44 | + // Define canHandleURL() to filter the video site URL you support |
| 45 | + FooVideo.canHandleURL = function(url) { |
| 46 | + return url.match(/foo/) |
| 47 | + }; |
| 48 | + |
| 49 | + // This is the “entry point” for your handler, from this point you can |
| 50 | + // do whatever your handler need to do to get the video final URL. |
| 51 | + FooVideo.prototype.start = function() { |
| 52 | + // ... |
| 53 | + // You can send a request to the background page in case you need to |
| 54 | + // fetch external resources using XHR. |
| 55 | + chrome.extension.sendRequest({action: 'ajax', |
| 56 | + args: { |
| 57 | + type: 'GET', |
| 58 | + url: myUrl |
| 59 | + }}, function(response) { |
| 60 | + /* do something with response.data and response.textStatus */ |
| 61 | + }); |
| 62 | + // ... |
| 63 | + // Invoke VideoHandlers.replaceFlashObjectWithVideo providing the |
| 64 | + // DOM object to substitute and the video URL to use. You can also |
| 65 | + // provide a watchURL and a downloadURL that will create links in the |
| 66 | + // interface for those actions. |
| 67 | + VideoHandlers.replaceFlashObjectWithVideo(this.domObject, |
| 68 | + videoURL, |
| 69 | + { watchURL: watchURL, downloadURL: downloadURL }); |
| 70 | + } |
| 71 | + |
| 72 | + // This is the end, so return your handler object |
| 73 | + return FooVideo; |
| 74 | + }) |
| 75 | + |
| 76 | +2. Modify video5.js to include your new handler:: |
| 77 | + |
| 78 | + VideoHandlers.register('youtube', 'foo'); |
| 79 | + ^^^^^ |
| 80 | + |
| 81 | + |
| 82 | +Authors |
| 83 | +------- |
| 84 | + |
| 85 | +Daniel Rodríguez Troitiño (drodriguez) |
| 86 | + Original implementation including Youtube support |
| 87 | + |
| 88 | +Yaohan Chen (hagabaka) |
| 89 | + Ideas and supporting code about the splitting the handlers code. |
| 90 | + Vimeo support. |
| 91 | + |
0 commit comments