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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 document.querySelector('#error').removeAttribute('visible'); | 273 document.querySelector('#error').removeAttribute('visible'); |
274 this.controls.inactivityWatcher.disabled = false; | 274 this.controls.inactivityWatcher.disabled = false; |
275 this.controls.decodeErrorOccured = false; | 275 this.controls.decodeErrorOccured = false; |
276 | 276 |
277 if (this.currentCast_) { | 277 if (this.currentCast_) { |
278 videoPlayerElement.setAttribute('casting', true); | 278 videoPlayerElement.setAttribute('casting', true); |
279 this.videoElement_ = new CastVideoElement(); | 279 this.videoElement_ = new CastVideoElement(); |
280 this.controls.attachMedia(this.videoElement_); | 280 this.controls.attachMedia(this.videoElement_); |
281 | 281 |
282 document.querySelector('#cast-name-label').textContent = | 282 document.querySelector('#cast-name-label').textContent = |
283 loadTimeData.getString('VIDEO_PLAYER_PLAYING_ON');; | 283 loadTimeData.getString('VIDEO_PLAYER_PLAYING_ON'); |
284 document.querySelector('#cast-name').textContent = this.currentCast_.name; | 284 document.querySelector('#cast-name').textContent = |
| 285 this.currentCast_.friendlyName; |
285 } else { | 286 } else { |
286 videoPlayerElement.removeAttribute('casting'); | 287 videoPlayerElement.removeAttribute('casting'); |
287 | 288 |
288 this.videoElement_ = document.createElement('video'); | 289 this.videoElement_ = document.createElement('video'); |
289 document.querySelector('#video-container').appendChild(this.videoElement_); | 290 document.querySelector('#video-container').appendChild(this.videoElement_); |
290 | 291 |
291 this.controls.attachMedia(this.videoElement_); | 292 this.controls.attachMedia(this.videoElement_); |
292 this.videoElement_.src = url; | 293 this.videoElement_.src = url; |
293 } | 294 } |
294 | 295 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 var currentVideo = this.videos_[this.currentPos_]; | 394 var currentVideo = this.videos_[this.currentPos_]; |
394 this.loadVideo_(currentVideo.fileUrl, currentVideo.entry.name, opt_callback); | 395 this.loadVideo_(currentVideo.fileUrl, currentVideo.entry.name, opt_callback); |
395 }; | 396 }; |
396 | 397 |
397 /** | 398 /** |
398 * Invokes when a menuitem in the cast menu is selected. | 399 * Invokes when a menuitem in the cast menu is selected. |
399 * @param {Object} cast Selected element in the list of casts. | 400 * @param {Object} cast Selected element in the list of casts. |
400 */ | 401 */ |
401 VideoPlayer.prototype.onCastSelected_ = function(cast) { | 402 VideoPlayer.prototype.onCastSelected_ = function(cast) { |
402 // If the selected item is same as the current item, do nothing. | 403 // If the selected item is same as the current item, do nothing. |
403 if ((this.currentCast_ && this.currentCast_.name) === (cast && cast.name)) | 404 if ((this.currentCast_ && this.currentCast_.label) === (cast && cast.label)) |
404 return; | 405 return; |
405 | 406 |
406 this.currentCast_ = cast || null; | 407 this.currentCast_ = cast || null; |
407 this.reloadCurrentVideo_(); | 408 this.reloadCurrentVideo_(); |
408 }; | 409 }; |
409 | 410 |
410 /** | 411 /** |
411 * Set the list of casts. | 412 * Set the list of casts. |
412 * @param {Array.<Object>} casts List of casts. | 413 * @param {Array.<Object>} casts List of casts. |
413 */ | 414 */ |
(...skipping 13 matching lines...) Expand all Loading... |
427 return; | 428 return; |
428 } | 429 } |
429 | 430 |
430 var item = new cr.ui.MenuItem(); | 431 var item = new cr.ui.MenuItem(); |
431 item.label = loadTimeData.getString('VIDEO_PLAYER_PLAY_THIS_COMPUTER'); | 432 item.label = loadTimeData.getString('VIDEO_PLAYER_PLAY_THIS_COMPUTER'); |
432 item.addEventListener('activate', this.onCastSelected_.wrap(this, null)); | 433 item.addEventListener('activate', this.onCastSelected_.wrap(this, null)); |
433 menu.appendChild(item); | 434 menu.appendChild(item); |
434 | 435 |
435 for (var i = 0; i < casts.length; i++) { | 436 for (var i = 0; i < casts.length; i++) { |
436 var item = new cr.ui.MenuItem(); | 437 var item = new cr.ui.MenuItem(); |
437 item.label = casts[i].name; | 438 item.label = casts[i].friendlyName; |
438 item.addEventListener('activate', | 439 item.addEventListener('activate', |
439 this.onCastSelected_.wrap(this, casts[i])); | 440 this.onCastSelected_.wrap(this, casts[i])); |
440 menu.appendChild(item); | 441 menu.appendChild(item); |
441 } | 442 } |
442 button.classList.remove('hidden'); | 443 button.classList.remove('hidden'); |
443 }; | 444 }; |
444 | 445 |
445 /** | 446 /** |
446 * Initialize the list of videos. | 447 * Initialize the list of videos. |
447 * @param {function(Array.<Object>)} callback Called with the video list when | 448 * @param {function(Array.<Object>)} callback Called with the video list when |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 var initPromise = Promise.all( | 480 var initPromise = Promise.all( |
480 [new Promise(initVideos.wrap(null)), | 481 [new Promise(initVideos.wrap(null)), |
481 new Promise(initStrings.wrap(null)), | 482 new Promise(initStrings.wrap(null)), |
482 new Promise(util.addPageLoadHandler.wrap(null))]); | 483 new Promise(util.addPageLoadHandler.wrap(null))]); |
483 | 484 |
484 initPromise.then(function(results) { | 485 initPromise.then(function(results) { |
485 var videos = results[0]; | 486 var videos = results[0]; |
486 player.prepare(videos); | 487 player.prepare(videos); |
487 return new Promise(player.playFirstVideo.wrap(player)); | 488 return new Promise(player.playFirstVideo.wrap(player)); |
488 }.wrap(null)); | 489 }.wrap(null)); |
OLD | NEW |