diff options
author | Valerio Virgillito | 2012-05-16 01:00:22 -0700 |
---|---|---|
committer | Valerio Virgillito | 2012-05-16 01:00:22 -0700 |
commit | f9f8fdc3000042ba5b4504d91870dc9a32ef25eb (patch) | |
tree | 606f22568ad2be0f7aed266a4d20de576f44002f /node_modules/montage-google/youtube-player.reel | |
parent | a9672abd32c2e03b8607c1af4903c90f7ff9531c (diff) | |
download | ninja-f9f8fdc3000042ba5b4504d91870dc9a32ef25eb.tar.gz |
Squashed master into dom-architecture
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'node_modules/montage-google/youtube-player.reel')
-rw-r--r-- | node_modules/montage-google/youtube-player.reel/youtube-player.html | 25 | ||||
-rw-r--r-- | node_modules/montage-google/youtube-player.reel/youtube-player.js | 216 |
2 files changed, 241 insertions, 0 deletions
diff --git a/node_modules/montage-google/youtube-player.reel/youtube-player.html b/node_modules/montage-google/youtube-player.reel/youtube-player.html new file mode 100644 index 00000000..d51cecdb --- /dev/null +++ b/node_modules/montage-google/youtube-player.reel/youtube-player.html | |||
@@ -0,0 +1,25 @@ | |||
1 | <!DOCTYPE html> | ||
2 | <!-- <copyright> | ||
3 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
4 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
5 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
6 | </copyright> --> | ||
7 | <html> | ||
8 | <head> | ||
9 | <title></title> | ||
10 | <script src="http://www.youtube.com/player_api"></script> | ||
11 | <script type="text/montage-serialization"> | ||
12 | { | ||
13 | "owner": { | ||
14 | "prototype": "montage-google/youtube-player.reel", | ||
15 | "properties": { | ||
16 | "element": {"#": "iframe"} | ||
17 | } | ||
18 | } | ||
19 | } | ||
20 | </script> | ||
21 | </head> | ||
22 | <body> | ||
23 | <iframe data-montage-id="iframe" class="montage-youtube-player" type="text/html" width="640" height="385" src="http://www.youtube.com/embed" frameborder="0" allowfullscreen></iframe> | ||
24 | </body> | ||
25 | </html> | ||
diff --git a/node_modules/montage-google/youtube-player.reel/youtube-player.js b/node_modules/montage-google/youtube-player.reel/youtube-player.js new file mode 100644 index 00000000..416ba76a --- /dev/null +++ b/node_modules/montage-google/youtube-player.reel/youtube-player.js | |||
@@ -0,0 +1,216 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | /*global require,exports,YT */ | ||
7 | var Montage = require("montage").Montage, | ||
8 | Component = require("montage/ui/component").Component; | ||
9 | |||
10 | var YoutubePlayer = exports.YoutubePlayer = Montage.create(Component, { | ||
11 | |||
12 | // Stores a queue of function calls to make on the player in the draw | ||
13 | // function | ||
14 | _playerQueue: { | ||
15 | enumerable: false, | ||
16 | value: [] | ||
17 | }, | ||
18 | |||
19 | _ready: { | ||
20 | enumerable: false, | ||
21 | value: false | ||
22 | }, | ||
23 | |||
24 | _player: { | ||
25 | enumerable: false, | ||
26 | value: null | ||
27 | }, | ||
28 | player: { | ||
29 | get: function() { | ||
30 | return this._player; | ||
31 | }, | ||
32 | set: function(value) { | ||
33 | if (this._player !== value) { | ||
34 | this._player = value; | ||
35 | } | ||
36 | } | ||
37 | }, | ||
38 | |||
39 | _width: { | ||
40 | enumerable: false, | ||
41 | value: 640 | ||
42 | }, | ||
43 | width: { | ||
44 | get: function() { | ||
45 | return this._width; | ||
46 | }, | ||
47 | set: function(value) { | ||
48 | if (this._width !== value) { | ||
49 | this._width = value; | ||
50 | this.needsDraw = true; | ||
51 | } | ||
52 | } | ||
53 | }, | ||
54 | _height: { | ||
55 | enumerable: false, | ||
56 | value: 385 | ||
57 | }, | ||
58 | height: { | ||
59 | get: function() { | ||
60 | return this._height; | ||
61 | }, | ||
62 | set: function(value) { | ||
63 | if (this._height !== value) { | ||
64 | this._height = value; | ||
65 | this.needsDraw = true; | ||
66 | } | ||
67 | } | ||
68 | }, | ||
69 | |||
70 | _autoplay: { | ||
71 | enumerable: false, | ||
72 | value: false | ||
73 | }, | ||
74 | autoplay: { | ||
75 | get: function() { | ||
76 | return this._autoplay; | ||
77 | }, | ||
78 | set: function(value) { | ||
79 | if (this._autoplay !== value) { | ||
80 | this._autoplay = value; | ||
81 | this.needsDraw = true; | ||
82 | } | ||
83 | } | ||
84 | }, | ||
85 | |||
86 | _videoId: { | ||
87 | enumerable: false, | ||
88 | value: null | ||
89 | }, | ||
90 | videoId: { | ||
91 | get: function() { | ||
92 | return this._videoId; | ||
93 | }, | ||
94 | set: function(value) { | ||
95 | if (this._videoId !== value) { | ||
96 | // TODO handle URLs as well | ||
97 | this._videoId = value; | ||
98 | |||
99 | // If the video isn't in the playlist, clear the playlist, | ||
100 | if (this._playlist && this._playlist.indexOf(value) === -1) { | ||
101 | this._playlist = null; | ||
102 | } | ||
103 | // TODO if the video is in the playlist use playVideoAt | ||
104 | |||
105 | if (this._autoplay) { | ||
106 | this._playerQueue.push(["loadVideoById", value]); | ||
107 | } else { | ||
108 | this._playerQueue.push(["cueVideoById", value]); | ||
109 | } | ||
110 | this.needsDraw = true; | ||
111 | } | ||
112 | } | ||
113 | }, | ||
114 | |||
115 | _playlist: { | ||
116 | enumerable: false, | ||
117 | value: null | ||
118 | }, | ||
119 | playlist: { | ||
120 | get: function() { | ||
121 | return this._playlist; | ||
122 | }, | ||
123 | set: function(value) { | ||
124 | if (this._playlist !== value) { | ||
125 | this._playlist = value; | ||
126 | |||
127 | if (this._autoplay) { | ||
128 | this._playerQueue.push(["loadPlaylist", value]); | ||
129 | } else { | ||
130 | this._playerQueue.push(["cuePlaylist", value]); | ||
131 | } | ||
132 | this.needsDraw = true; | ||
133 | } | ||
134 | } | ||
135 | }, | ||
136 | |||
137 | play: { | ||
138 | value: function() { | ||
139 | this._playerQueue.push("playVideo"); | ||
140 | this.needsDraw = true; | ||
141 | } | ||
142 | }, | ||
143 | pause: { | ||
144 | value: function() { | ||
145 | this._playerQueue.push("pauseVideo"); | ||
146 | this.needsDraw = true; | ||
147 | } | ||
148 | }, | ||
149 | stop: { | ||
150 | value: function() { | ||
151 | this._playerQueue.push("stopVideo"); | ||
152 | this.needsDraw = true; | ||
153 | } | ||
154 | }, | ||
155 | |||
156 | prepareForDraw: { | ||
157 | value: function() { | ||
158 | // Create the callback if it doesn't exist, and make it dispatch | ||
159 | // an event on the document instead | ||
160 | if (!window.onYouTubePlayerAPIReady) { | ||
161 | window.onYouTubePlayerAPIReady = function() { | ||
162 | var event = document.createEvent("CustomEvent"); | ||
163 | event.initEvent("youtubePlayerApiReady", true, true); | ||
164 | document.dispatchEvent(event); | ||
165 | }; | ||
166 | } | ||
167 | |||
168 | this._element.src += (this._videoId ? "/" + this._videoId : "") + "?enablejsapi=1"; | ||
169 | |||
170 | if (typeof YT !== "undefined" && YT.Player) { | ||
171 | this.handleYoutubePlayerApiReady(); | ||
172 | } else { | ||
173 | document.addEventListener("youtubePlayerApiReady", this, false); | ||
174 | } | ||
175 | } | ||
176 | }, | ||
177 | |||
178 | handleYoutubePlayerApiReady: { | ||
179 | value: function(event) { | ||
180 | document.removeEventListener("youtubePlayerApiReady", this); | ||