| 1 | /* |
| 2 | * Copyright 2012 YouTube LLC |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | /** |
| 18 | * Public API calls. |
| 19 | * @link http://code.google.com/apis/youtube/js_api_reference.html |
| 20 | * @externs |
| 21 | */ |
| 22 | |
| 23 | |
| 24 | /** |
| 25 | * @constructor |
| 26 | * @extends {HTMLObjectElement} |
| 27 | */ |
| 28 | |
| 29 | function YouTubePlayer() {} |
| 30 | |
| 31 | |
| 32 | /** |
| 33 | * Plays the currently cued/loaded video. |
| 34 | * |
| 35 | */ |
| 36 | YouTubePlayer.prototype.playVideo = function() {}; |
| 37 | |
| 38 | |
| 39 | /** |
| 40 | * Pauses the currently playing video. |
| 41 | */ |
| 42 | YouTubePlayer.prototype.pauseVideo = function() {}; |
| 43 | |
| 44 | |
| 45 | /** |
| 46 | * Stops the current video. This function also closes the NetStream object and cancels the loading of the video. |
| 47 | */ |
| 48 | YouTubePlayer.prototype.stopVideo = function() {}; |
| 49 | |
| 50 | |
| 51 | /** |
| 52 | * Clears the video display. This function is useful if you want to clear the video remnant after calling stopVideo(). |
| 53 | */ |
| 54 | YouTubePlayer.prototype.clearVideo = function() {}; |
| 55 | |
| 56 | |
| 57 | /** |
| 58 | * @return {number} The number of bytes loaded for the current video. |
| 59 | */ |
| 60 | YouTubePlayer.prototype.getVideoBytesLoaded = function() {}; |
| 61 | |
| 62 | |
| 63 | /** |
| 64 | * @return {number} The size in bytes of the currently loaded/playing video. |
| 65 | */ |
| 66 | YouTubePlayer.prototype.getVideoBytesTotal = function() {}; |
| 67 | |
| 68 | |
| 69 | /** |
| 70 | * @return {number} The number of bytes the video file started loading from. |
| 71 | */ |
| 72 | YouTubePlayer.prototype.getVideoStartBytes = function() {}; |
| 73 | |
| 74 | |
| 75 | /** |
| 76 | * @return {Array} The current playlist as an array of video IDs. |
| 77 | */ |
| 78 | YouTubePlayer.prototype.getPlaylist = function() {}; |
| 79 | |
| 80 | |
| 81 | /** |
| 82 | * @return {number} The current index in the playlist or -1 when the player has |
| 83 | * no playlist. |
| 84 | */ |
| 85 | YouTubePlayer.prototype.getPlaylistIndex = function() {}; |
| 86 | |
| 87 | |
| 88 | /** |
| 89 | * Calls an option method on the module |
| 90 | * @param {string} moduleId The module descriptor id. |
| 91 | * @param {string} option The option to call on the module. |
| 92 | * @param {*} object Arbitrary data to be sent to the module. |
| 93 | * @return {Object} Returns null if module or option doesn't exist. |
| 94 | */ |
| 95 | YouTubePlayer.prototype.setOption = function(moduleId, option, object) {}; |
| 96 | |
| 97 | |
| 98 | /** |
| 99 | * Calls an option method on the module |
| 100 | * @param {string} moduleId The module descriptor id. |
| 101 | * @param {string} option The option to call on the module. |
| 102 | * @param {*} object Arbitrary data to be sent to the module. |
| 103 | * @return {Object} Returns null if module or option doesn't exist. |
| 104 | */ |
| 105 | YouTubePlayer.prototype.getOption = function(moduleId, option, object) {}; |
| 106 | |
| 107 | |
| 108 | /** |
| 109 | * @return {?string} The current playlist's list id if there is a playlist and |
| 110 | * that playlist was loaded from a list id, otherwise returns null. |
| 111 | */ |
| 112 | YouTubePlayer.prototype.getPlaylistId = function() {}; |
| 113 | |
| 114 | |
| 115 | /** |
| 116 | * Mutes the player. |
| 117 | */ |
| 118 | YouTubePlayer.prototype.mute = function() {}; |
| 119 | |
| 120 | |
| 121 | /** |
| 122 | * Unmutes the player. |
| 123 | */ |
| 124 | YouTubePlayer.prototype.unMute = function() {}; |
| 125 | |
| 126 | |
| 127 | /** |
| 128 | * @return {boolean} true if the player is muted, false if not. |
| 129 | */ |
| 130 | YouTubePlayer.prototype.isMuted = function() {}; |
| 131 | |
| 132 | |
| 133 | /** |
| 134 | * @param {number} volume The volume, an integer between 0 and 100. |
| 135 | */ |
| 136 | YouTubePlayer.prototype.setVolume = function(volume) {}; |
| 137 | |
| 138 | |
| 139 | /** |
| 140 | * @return {number} The player's current volume, an integer between 0 and 100. |
| 141 | */ |
| 142 | YouTubePlayer.prototype.getVolume = function() {}; |
| 143 | |
| 144 | |
| 145 | /** |
| 146 | * Seeks to the specified time of the video in seconds. |
| 147 | * @param {number} seconds The offset to seek to. |
| 148 | * @param {boolean=} opt_allowSeekAhead If true the player will make a new |
| 149 | * server request if seconds is beyond the currently loaded video data. |
| 150 | */ |
| 151 | YouTubePlayer.prototype.seekTo = function(seconds, opt_allowSeekAhead) {}; |
| 152 | |
| 153 | |
| 154 | /** |
| 155 | * @return {number} The state of the player. Possible values are unstarted |
| 156 | * (-1), ended (0), playing (1), paused (2), buffering (3), video cued (5). |
| 157 | */ |
| 158 | YouTubePlayer.prototype.getPlayerState = function() {}; |
| 159 | |
| 160 | |
| 161 | /** |
| 162 | * Returns the current playback rate setting of the player. |
| 163 | * @return {number} The current playback rate setting of the player. |
| 164 | */ |
| 165 | YouTubePlayer.prototype.getPlaybackRate = function() {}; |
| 166 | |
| 167 | |
| 168 | /** |
| 169 | * Sets the playback rate for the player based on the rate suggested by the |
| 170 | * user. The actually applied rate is the closest supported rate that lies |
| 171 | * between 1.0 and the suggested rate (inclusive). 1.0 will always be one |
| 172 | * of the supported playback rates. |
| 173 | * @param {number} suggestedRate The playback rate suggested by the user. |
| 174 | */ |
| 175 | YouTubePlayer.prototype.setPlaybackRate = function(suggestedRate) {}; |
| 176 | |
| 177 | |
| 178 | /** |
| 179 | * Gets an array of playback rates supported by the video player, sorted in |
| 180 | * ascending order. This array is guaranteed to have the entry 1.0. |
| 181 | * @return {Array.<number>} Playback rates supported by the player. |
| 182 | */ |
| 183 | YouTubePlayer.prototype.getAvailablePlaybackRates = function() {}; |
| 184 | |
| 185 | |
| 186 | /** |
| 187 | * @return {string} The current quality the player has loaded or is playing. |
| 188 | */ |
| 189 | YouTubePlayer.prototype.getPlaybackQuality = function() {}; |
| 190 | |
| 191 | |
| 192 | /** |
| 193 | * Sets the playback quality in the video player. If the quality is not the |
| 194 | * current playing quality, the player will load the new quality. |
| 195 | * @param {string} quality The video quality the player should load and play. |
| 196 | */ |
| 197 | YouTubePlayer.prototype.setPlaybackQuality = function(quality) {}; |
| 198 | |
| 199 | |
| 200 | /** |
| 201 | * @return {Array} Array of available quality levels in order of decreasing quality. |
| 202 | */ |
| 203 | YouTubePlayer.prototype.getAvailableQualityLevels = function() {}; |
| 204 | |
| 205 | |
| 206 | /** |
| 207 | * @return {number} The elapsed time in seconds since the video started playing. |
| 208 | */ |
| 209 | YouTubePlayer.prototype.getCurrentTime = function() {}; |
| 210 | |
| 211 | |
| 212 | /** |
| 213 | * @return {number} The duration in seconds of the currently playing video. |
| 214 | */ |
| 215 | YouTubePlayer.prototype.getDuration = function() {}; |
| 216 | |
| 217 | |
| 218 | /** |
| 219 | * @param {string} event The event to listen for. |
| 220 | * @param {string|EventListener|Function} listener The function to call |
| 221 | * when the event occurs. |
| 222 | */ |
| 223 | YouTubePlayer.prototype.addEventListener = function(event, listener) {}; |
| 224 | |
| 225 | |
| 226 | /** |
| 227 | * @return {string} The YouTube.com URL for the currently loaded/playing video. |
| 228 | */ |
| 229 | YouTubePlayer.prototype.getVideoUrl = function() {}; |
| 230 | |
| 231 | |
| 232 | /** |
| 233 | * @return {string} The embed code for the currently loaded/playing video. |
| 234 | */ |
| 235 | YouTubePlayer.prototype.getVideoEmbedCode = function() {}; |
| 236 | |
| 237 | |
| 238 | /** |
| 239 | * Loads the specified video's thumbnail and prepares the player to play the |
| 240 | * video. |
| 241 | * @param {Object|string} videoIdOrObject YouTube Video ID or object. |
| 242 | * @param {number} opt_startSeconds The video will start from the keyframe |
| 243 | * nearest this time. |
| 244 | */ |
| 245 | YouTubePlayer.prototype.cueVideoById = |
| 246 | function(videoIdOrObject, opt_startSeconds) {}; |
| 247 | |
| 248 | |
| 249 | /** |
| 250 | * Loads and plays the specified video. |
| 251 | * @param {Object|string} videoIdOrObject YouTube Video ID or object. |
| 252 | * @param {number} opt_startSeconds The video will start from the keyframe |
| 253 | * nearest this time. |
| 254 | */ |
| 255 | YouTubePlayer.prototype.loadVideoById = |
| 256 | function(videoIdOrObject, opt_startSeconds) {}; |
| 257 | |
| 258 | |
| 259 | /** |
| 260 | * Loads the specified video's thumbnail and prepares the player to play the video. |
| 261 | * @param {string} mediaContentUrl YouTube player URL in the format |
| 262 | * http://www.youtube.com/v/VIDEO_ID. |
| 263 | * @param {number} opt_startSeconds The video will start from the keyframe nearest this time. |
| 264 | */ |
| 265 | YouTubePlayer.prototype.cueVideoByUrl = function(mediaContentUrl, opt_startSeconds) {}; |
| 266 | |
| 267 | |
| 268 | /** |
| 269 | * Loads and plays the specified video. |
| 270 | * @param {string} mediaContentUrl YouTube player URL in the format |
| 271 | * http://www.youtube.com/v/VIDEO_ID. |
| 272 | * @param {number} opt_startSeconds The video will start from the keyframe nearest this time. |
| 273 | */ |
| 274 | YouTubePlayer.prototype.loadVideoByUrl = function(mediaContentUrl, opt_startSeconds) {}; |
| 275 | |
| 276 | |
| 277 | /** |
| 278 | * Loads and plays a specified video in a playlist. |
| 279 | * @param {string|Array|Object} playlistOrObject An object containing all of the |
| 280 | * parameters. Otherwise, a string that is a playlist id (without |
| 281 | * the PL list prefix) or an array of video ids. |
| 282 | * @param {number=} opt_index The index to begin playback at. |
| 283 | * @param {number=} opt_startSeconds Float/integer that specifies the time |
| 284 | * from which the video should start playing. |
| 285 | * @param {string=} opt_suggestedQuality The suggested playback quality for |
| 286 | * the video. |
| 287 | */ |
| 288 | YouTubePlayer.prototype.cuePlaylist = function(playlistOrObject, |
| 289 | opt_index, opt_startSeconds, opt_suggestedQuality) {}; |
| 290 | |
| 291 | |
| 292 | /** |
| 293 | * Loads and cues a specified video in a playlist. |
| 294 | * @param {string|Array|Object} playlistOrObject An object containing all of the |
| 295 | * parameters. Otherwise, a string that is a playlist id (without |
| 296 | * the PL list prefix) or an array of video ids. |
| 297 | * @param {number=} opt_index The index to begin playback at. |
| 298 | * @param {number=} opt_startSeconds Float/integer that specifies the time |
| 299 | * from which the video should start playing. |
| 300 | * @param {string=} opt_suggestedQuality The suggested playback quality for |
| 301 | * the video. |
| 302 | */ |
| 303 | YouTubePlayer.prototype.loadPlaylist = function(playlistOrObject, |
| 304 | opt_index, opt_startSeconds, opt_suggestedQuality) {}; |
| 305 | |
| 306 | |
| 307 | /** |
| 308 | * Plays the next video in the playlist. At the end of the playlist, this will |
| 309 | * go to the first video when loop is enabled, otherwise it will be a noop. |
| 310 | */ |
| 311 | YouTubePlayer.prototype.nextVideo = function() {}; |
| 312 | |
| 313 | |
| 314 | /** |
| 315 | * Plays the previous video in the playlist. At the front of the playlist, this |
| 316 | * will go to the last video when loop is enabled, otherwise it will be a noop. |
| 317 | */ |
| 318 | YouTubePlayer.prototype.previousVideo = function() {}; |
| 319 | |
| 320 | |
| 321 | /** |
| 322 | * Plays a specific video in the playlist. If the provided index is not in the |
| 323 | * playlist, this will be a noop. |
| 324 | * @param {number} index The index of the video in the playlist to play. |
| 325 | */ |
| 326 | YouTubePlayer.prototype.playVideoAt = function(index) {}; |
| 327 | |
| 328 | |
| 329 | /** |
| 330 | * Shuffle the playlist when setting shuffle to true, or return the playlist to |
| 331 | * the original order when setting to false. |
| 332 | * @param {boolean} shuffle If the playlist should shuffle. |
| 333 | */ |
| 334 | YouTubePlayer.prototype.setShuffle = function(shuffle) {}; |
| 335 | |
| 336 | |
| 337 | /** |
| 338 | * @param {boolean} loop If the playlist should loop. |
| 339 | */ |
| 340 | YouTubePlayer.prototype.setLoop = function(loop) {}; |
| 341 | |
| 342 | |
| 343 | /** |
| 344 | * Sets the size in pixels of the player. You should not have to use this |
| 345 | * method in JavaScript as the player will automatically resize when the |
| 346 | * containing elements in the embed code have their height and width |
| 347 | * properties modified. |
| 348 | * @param {number} width Player width. |
| 349 | * @param {number} height Player height. |
| 350 | */ |
| 351 | YouTubePlayer.prototype.setSize = function(width, height) {}; |
| 352 | |
| 353 | |
| 354 | /** |
| 355 | * Destroys the player reference. |
| 356 | */ |
| 357 | YouTubePlayer.prototype.destroy = function() {}; |
| 358 | |
| 359 | |
| 360 | /** |
| 361 | * On player ready callback. |
| 362 | * |
| 363 | * @param {string} playerapiid String identifier for a player. |
| 364 | */ |
| 365 | function onYouTubePlayerReady(playerapiid) {} |
| 366 | |
| 367 | |
| 368 | /** |
| 369 | * On player ready callback. |
| 370 | * |
| 371 | * @param {string} playerapiid String identifier for a player. |
| 372 | */ |
| 373 | Window.prototype.onYouTubePlayerReady = function(playerapiid) {}; |