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