| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 86 |
| 87 FullWindowVideoControls.prototype = { __proto__: VideoControls.prototype }; | 87 FullWindowVideoControls.prototype = { __proto__: VideoControls.prototype }; |
| 88 | 88 |
| 89 /** | 89 /** |
| 90 * Displays error message. | 90 * Displays error message. |
| 91 * | 91 * |
| 92 * @param {string} message Message id. | 92 * @param {string} message Message id. |
| 93 */ | 93 */ |
| 94 FullWindowVideoControls.prototype.showErrorMessage = function(message) { | 94 FullWindowVideoControls.prototype.showErrorMessage = function(message) { |
| 95 var errorBanner = document.querySelector('#error'); | 95 var errorBanner = document.querySelector('#error'); |
| 96 errorBanner.textContent = | 96 errorBanner.textContent = loadTimeData.getString(message); |
| 97 loadTimeData.getString(message); | |
| 98 errorBanner.setAttribute('visible', 'true'); | 97 errorBanner.setAttribute('visible', 'true'); |
| 99 | 98 |
| 100 // The window is hidden if the video has not loaded yet. | 99 // The window is hidden if the video has not loaded yet. |
| 101 chrome.app.window.current().show(); | 100 chrome.app.window.current().show(); |
| 102 }; | 101 }; |
| 103 | 102 |
| 104 /** | 103 /** |
| 105 * Handles playback (decoder) errors. | 104 * Handles playback (decoder) errors. |
| 106 * @param {MediaError} error Error object. | 105 * @param {MediaError} error Error object. |
| 107 * @private | 106 * @private |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 arrowRight.addEventListener('click', this.advance_.wrap(this, 1)); | 249 arrowRight.addEventListener('click', this.advance_.wrap(this, 1)); |
| 251 var arrowLeft = document.querySelector('.arrow-box .arrow.left'); | 250 var arrowLeft = document.querySelector('.arrow-box .arrow.left'); |
| 252 arrowLeft.addEventListener('click', this.advance_.wrap(this, 0)); | 251 arrowLeft.addEventListener('click', this.advance_.wrap(this, 0)); |
| 253 | 252 |
| 254 var videoPlayerElement = document.querySelector('#video-player'); | 253 var videoPlayerElement = document.querySelector('#video-player'); |
| 255 if (videos.length > 1) | 254 if (videos.length > 1) |
| 256 videoPlayerElement.setAttribute('multiple', true); | 255 videoPlayerElement.setAttribute('multiple', true); |
| 257 else | 256 else |
| 258 videoPlayerElement.removeAttribute('multiple'); | 257 videoPlayerElement.removeAttribute('multiple'); |
| 259 | 258 |
| 260 document.querySelector('#cast-menu').setAttribute( | |
| 261 'playon-text', | |
| 262 loadTimeData.getString('VIDEO_PLAYER_PLAY_ON')); | |
| 263 | |
| 264 document.addEventListener('keydown', reloadVideo); | 259 document.addEventListener('keydown', reloadVideo); |
| 265 document.addEventListener('click', reloadVideo); | 260 document.addEventListener('click', reloadVideo); |
| 266 }; | 261 }; |
| 267 | 262 |
| 268 /** | 263 /** |
| 269 * Unloads the player. | 264 * Unloads the player. |
| 270 */ | 265 */ |
| 271 function unload() { | 266 function unload() { |
| 272 // Releases keep awake just in case (should be released on unloading video). | 267 // Releases keep awake just in case (should be released on unloading video). |
| 273 chrome.power.releaseKeepAwake(); | 268 chrome.power.releaseKeepAwake(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 'url(' + url + '&access_token=' + token + ')'; | 319 'url(' + url + '&access_token=' + token + ')'; |
| 325 }).catch(function() { | 320 }).catch(function() { |
| 326 // Shows no image on error. | 321 // Shows no image on error. |
| 327 document.querySelector('#thumbnail').style.backgroundImage = ''; | 322 document.querySelector('#thumbnail').style.backgroundImage = ''; |
| 328 }); | 323 }); |
| 329 | 324 |
| 330 var videoElementInitializePromise; | 325 var videoElementInitializePromise; |
| 331 if (this.currentCast_) { | 326 if (this.currentCast_) { |
| 332 videoPlayerElement.setAttribute('casting', true); | 327 videoPlayerElement.setAttribute('casting', true); |
| 333 | 328 |
| 334 document.querySelector('#cast-name-label').textContent = | |
| 335 loadTimeData.getString('VIDEO_PLAYER_PLAYING_ON'); | |
| 336 document.querySelector('#cast-name').textContent = | 329 document.querySelector('#cast-name').textContent = |
| 337 this.currentCast_.friendlyName; | 330 this.currentCast_.friendlyName; |
| 338 | 331 |
| 339 videoPlayerElement.setAttribute('castable', true); | 332 videoPlayerElement.setAttribute('castable', true); |
| 340 | 333 |
| 341 videoElementInitializePromise = | 334 videoElementInitializePromise = |
| 342 media.isAvailableForCast().then(function(result) { | 335 media.isAvailableForCast().then(function(result) { |
| 343 if (!result) | 336 if (!result) |
| 344 return Promise.reject('No casts are available.'); | 337 return Promise.reject('No casts are available.'); |
| 345 | 338 |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 var currentCastAvailable = casts.some(function(cast) { | 553 var currentCastAvailable = casts.some(function(cast) { |
| 561 return this.currentCast_.label === cast.label; | 554 return this.currentCast_.label === cast.label; |
| 562 }.wrap(this)); | 555 }.wrap(this)); |
| 563 | 556 |
| 564 if (!currentCastAvailable) | 557 if (!currentCastAvailable) |
| 565 this.onCurrentCastDisappear_(); | 558 this.onCurrentCastDisappear_(); |
| 566 } | 559 } |
| 567 | 560 |
| 568 var item = new cr.ui.MenuItem(); | 561 var item = new cr.ui.MenuItem(); |
| 569 item.label = loadTimeData.getString('VIDEO_PLAYER_PLAY_THIS_COMPUTER'); | 562 item.label = loadTimeData.getString('VIDEO_PLAYER_PLAY_THIS_COMPUTER'); |
| 563 item.setAttribute('aria-label', item.label); |
| 570 item.castLabel = ''; | 564 item.castLabel = ''; |
| 571 item.addEventListener('activate', this.onCastSelected_.wrap(this, null)); | 565 item.addEventListener('activate', this.onCastSelected_.wrap(this, null)); |
| 572 menu.appendChild(item); | 566 menu.appendChild(item); |
| 573 | 567 |
| 574 for (var i = 0; i < casts.length; i++) { | 568 for (var i = 0; i < casts.length; i++) { |
| 575 var item = new cr.ui.MenuItem(); | 569 var item = new cr.ui.MenuItem(); |
| 576 item.label = casts[i].friendlyName; | 570 item.label = casts[i].friendlyName; |
| 571 item.setAttribute('aria-label', item.label); |
| 577 item.castLabel = casts[i].label; | 572 item.castLabel = casts[i].label; |
| 578 item.addEventListener('activate', | 573 item.addEventListener('activate', |
| 579 this.onCastSelected_.wrap(this, casts[i])); | 574 this.onCastSelected_.wrap(this, casts[i])); |
| 580 menu.appendChild(item); | 575 menu.appendChild(item); |
| 581 } | 576 } |
| 582 this.updateCheckOnCastMenu_(); | 577 this.updateCheckOnCastMenu_(); |
| 583 videoPlayerElement.setAttribute('cast-available', true); | 578 videoPlayerElement.setAttribute('cast-available', true); |
| 584 }; | 579 }; |
| 585 | 580 |
| 586 /** | 581 /** |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 | 650 |
| 656 var player = new VideoPlayer(); | 651 var player = new VideoPlayer(); |
| 657 | 652 |
| 658 /** | 653 /** |
| 659 * Initializes the strings. | 654 * Initializes the strings. |
| 660 * @param {function()} callback Called when the sting data is ready. | 655 * @param {function()} callback Called when the sting data is ready. |
| 661 */ | 656 */ |
| 662 function initStrings(callback) { | 657 function initStrings(callback) { |
| 663 chrome.fileManagerPrivate.getStrings(function(strings) { | 658 chrome.fileManagerPrivate.getStrings(function(strings) { |
| 664 loadTimeData.data = strings; | 659 loadTimeData.data = strings; |
| 660 i18nTemplate.process(document, loadTimeData); |
| 665 callback(); | 661 callback(); |
| 666 }.wrap(null)); | 662 }.wrap(null)); |
| 667 } | 663 } |
| 668 | 664 |
| 669 var initPromise = Promise.all( | 665 var initPromise = Promise.all( |
| 670 [new Promise(initVideos.wrap(null)), | 666 [new Promise(initVideos.wrap(null)), |
| 671 new Promise(initStrings.wrap(null)), | 667 new Promise(initStrings.wrap(null)), |
| 672 new Promise(util.addPageLoadHandler.wrap(null))]); | 668 new Promise(util.addPageLoadHandler.wrap(null))]); |
| 673 | 669 |
| 674 initPromise.then(function(results) { | 670 initPromise.then(function(results) { |
| 675 var videos = results[0]; | 671 var videos = results[0]; |
| 676 player.prepare(videos); | 672 player.prepare(videos); |
| 677 return new Promise(player.playFirstVideo.wrap(player)); | 673 return new Promise(player.playFirstVideo.wrap(player)); |
| 678 }.wrap(null)); | 674 }.wrap(null)); |
| OLD | NEW |