Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 'use strict'; | 5 'use strict'; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * @param {Element} playerContainer Main container. | 8 * @param {Element} playerContainer Main container. |
| 9 * @param {Element} videoContainer Container for the video element. | 9 * @param {Element} videoContainer Container for the video element. |
| 10 * @param {Element} controlsContainer Container for video controls. | 10 * @param {Element} controlsContainer Container for video controls. |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 | 158 |
| 159 var closeButton = document.querySelector('.close-button'); | 159 var closeButton = document.querySelector('.close-button'); |
| 160 closeButton.addEventListener( | 160 closeButton.addEventListener( |
| 161 'click', | 161 'click', |
| 162 function(event) { | 162 function(event) { |
| 163 close(); | 163 close(); |
| 164 event.stopPropagation(); | 164 event.stopPropagation(); |
| 165 }.wrap(null)); | 165 }.wrap(null)); |
| 166 closeButton.addEventListener('mousedown', preventDefault); | 166 closeButton.addEventListener('mousedown', preventDefault); |
| 167 | 167 |
| 168 var castButton = document.querySelector('.cast-button'); | |
| 169 cr.ui.decorate(castButton, cr.ui.MenuButton); | |
| 170 castButton.addEventListener( | |
| 171 'click', | |
| 172 function(event) { | |
| 173 event.stopPropagation(); | |
| 174 }.wrap(this)); | |
|
fukino
2014/07/11 04:35:51
null is OK for now?
| |
| 175 castButton.addEventListener('mousedown', preventDefault); | |
| 176 | |
| 177 var menu = document.querySelector('#cast-menu'); | |
| 178 cr.ui.decorate(menu, cr.ui.Menu); | |
| 179 | |
| 168 this.controls_ = new FullWindowVideoControls( | 180 this.controls_ = new FullWindowVideoControls( |
| 169 document.querySelector('#video-player'), | 181 document.querySelector('#video-player'), |
| 170 document.querySelector('#video-container'), | 182 document.querySelector('#video-container'), |
| 171 document.querySelector('#controls')); | 183 document.querySelector('#controls')); |
| 172 | 184 |
| 173 var reloadVideo = function(e) { | 185 var reloadVideo = function(e) { |
| 174 if (this.controls_.decodeErrorOccured && | 186 if (this.controls_.decodeErrorOccured && |
| 175 // Ignore shortcut keys | 187 // Ignore shortcut keys |
| 176 !e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey) { | 188 !e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey) { |
| 177 this.reloadCurrentVideo_(function() { | 189 this.reloadCurrentVideo_(function() { |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 338 * Reloads the current video. | 350 * Reloads the current video. |
| 339 * | 351 * |
| 340 * @param {function()=} opt_callback Completion callback. | 352 * @param {function()=} opt_callback Completion callback. |
| 341 * @private | 353 * @private |
| 342 */ | 354 */ |
| 343 VideoPlayer.prototype.reloadCurrentVideo_ = function(opt_callback) { | 355 VideoPlayer.prototype.reloadCurrentVideo_ = function(opt_callback) { |
| 344 var currentVideo = this.videos_[this.currentPos_]; | 356 var currentVideo = this.videos_[this.currentPos_]; |
| 345 this.loadVideo_(currentVideo.fileUrl, currentVideo.entry.name, opt_callback); | 357 this.loadVideo_(currentVideo.fileUrl, currentVideo.entry.name, opt_callback); |
| 346 }; | 358 }; |
| 347 | 359 |
| 360 VideoPlayer.prototype.setCastList= function(casts) { | |
|
fukino
2014/07/11 04:35:51
nit: A space missing before '='
| |
| 361 var button = document.querySelector('.cast-button'); | |
| 362 var menu = document.querySelector('#cast-menu'); | |
| 363 menu.innerHTML = ''; | |
| 364 | |
| 365 if (casts.length === 0) { | |
| 366 button.classList.add('hidden'); | |
| 367 return; | |
| 368 } | |
| 369 | |
| 370 for (var i = 0; i < casts.length; i++) { | |
| 371 var item = new cr.ui.MenuItem(); | |
| 372 item.textContent = casts[i].name; | |
| 373 menu.appendChild(item); | |
| 374 } | |
| 375 button.classList.remove('hidden'); | |
| 376 }; | |
| 377 | |
| 348 /** | 378 /** |
| 349 * Initialize the list of videos. | 379 * Initialize the list of videos. |
| 350 * @param {function(Array.<Object>)} callback Called with the video list when | 380 * @param {function(Array.<Object>)} callback Called with the video list when |
| 351 * it is ready. | 381 * it is ready. |
| 352 */ | 382 */ |
| 353 function initVideos(callback) { | 383 function initVideos(callback) { |
| 354 if (window.videos) { | 384 if (window.videos) { |
| 355 var videos = window.videos; | 385 var videos = window.videos; |
| 356 window.videos = null; | 386 window.videos = null; |
| 357 callback(videos); | 387 callback(videos); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 382 var initPromise = Promise.all( | 412 var initPromise = Promise.all( |
| 383 [new Promise(initVideos.wrap(null)), | 413 [new Promise(initVideos.wrap(null)), |
| 384 new Promise(initStrings.wrap(null)), | 414 new Promise(initStrings.wrap(null)), |
| 385 new Promise(util.addPageLoadHandler.wrap(null))]); | 415 new Promise(util.addPageLoadHandler.wrap(null))]); |
| 386 | 416 |
| 387 initPromise.then(function(results) { | 417 initPromise.then(function(results) { |
| 388 var videos = results[0]; | 418 var videos = results[0]; |
| 389 player.prepare(videos); | 419 player.prepare(videos); |
| 390 return new Promise(player.playFirstVideo.wrap(player)); | 420 return new Promise(player.playFirstVideo.wrap(player)); |
| 391 }.wrap(null)); | 421 }.wrap(null)); |
| OLD | NEW |