| 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 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 | 496 |
| 497 /** | 497 /** |
| 498 * Invokes when a menuitem in the cast menu is selected. | 498 * Invokes when a menuitem in the cast menu is selected. |
| 499 * @param {Object} cast Selected element in the list of casts. | 499 * @param {Object} cast Selected element in the list of casts. |
| 500 */ | 500 */ |
| 501 VideoPlayer.prototype.onCastSelected_ = function(cast) { | 501 VideoPlayer.prototype.onCastSelected_ = function(cast) { |
| 502 // If the selected item is same as the current item, do nothing. | 502 // If the selected item is same as the current item, do nothing. |
| 503 if ((this.currentCast_ && this.currentCast_.label) === (cast && cast.label)) | 503 if ((this.currentCast_ && this.currentCast_.label) === (cast && cast.label)) |
| 504 return; | 504 return; |
| 505 | 505 |
| 506 this.currentCast_ = cast || null; | 506 this.unloadVideo(false); |
| 507 this.updateCheckOnCastMenu_(); | 507 |
| 508 this.reloadCurrentVideo(); | 508 // Waits for unloading video. |
| 509 this.loadQueue_.run(function(callback) { |
| 510 this.currentCast_ = cast || null; |
| 511 this.updateCheckOnCastMenu_(); |
| 512 this.reloadCurrentVideo(); |
| 513 callback(); |
| 514 }.wrap(this)); |
| 509 }; | 515 }; |
| 510 | 516 |
| 511 /** | 517 /** |
| 512 * Set the list of casts. | 518 * Set the list of casts. |
| 513 * @param {Array.<Object>} casts List of casts. | 519 * @param {Array.<Object>} casts List of casts. |
| 514 */ | 520 */ |
| 515 VideoPlayer.prototype.setCastList = function(casts) { | 521 VideoPlayer.prototype.setCastList = function(casts) { |
| 516 var videoPlayerElement = document.querySelector('#video-player'); | 522 var videoPlayerElement = document.querySelector('#video-player'); |
| 517 var menu = document.querySelector('#cast-menu'); | 523 var menu = document.querySelector('#cast-menu'); |
| 518 menu.innerHTML = ''; | 524 menu.innerHTML = ''; |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 var initPromise = Promise.all( | 643 var initPromise = Promise.all( |
| 638 [new Promise(initVideos.wrap(null)), | 644 [new Promise(initVideos.wrap(null)), |
| 639 new Promise(initStrings.wrap(null)), | 645 new Promise(initStrings.wrap(null)), |
| 640 new Promise(util.addPageLoadHandler.wrap(null))]); | 646 new Promise(util.addPageLoadHandler.wrap(null))]); |
| 641 | 647 |
| 642 initPromise.then(function(results) { | 648 initPromise.then(function(results) { |
| 643 var videos = results[0]; | 649 var videos = results[0]; |
| 644 player.prepare(videos); | 650 player.prepare(videos); |
| 645 return new Promise(player.playFirstVideo.wrap(player)); | 651 return new Promise(player.playFirstVideo.wrap(player)); |
| 646 }.wrap(null)); | 652 }.wrap(null)); |
| OLD | NEW |