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 /** | 5 /** |
6 * @param {Element} playerContainer Main container. | 6 * @param {Element} playerContainer Main container. |
7 * @param {Element} videoContainer Container for the video element. | 7 * @param {Element} videoContainer Container for the video element. |
8 * @param {Element} controlsContainer Container for video controls. | 8 * @param {Element} controlsContainer Container for video controls. |
9 * @constructor | 9 * @constructor |
10 */ | 10 */ |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
311 document.querySelector('#thumbnail').style.backgroundImage = ''; | 311 document.querySelector('#thumbnail').style.backgroundImage = ''; |
312 } | 312 } |
313 }) | 313 }) |
314 .catch(function() { | 314 .catch(function() { |
315 // Shows no image on error. | 315 // Shows no image on error. |
316 document.querySelector('#thumbnail').style.backgroundImage = ''; | 316 document.querySelector('#thumbnail').style.backgroundImage = ''; |
317 }); | 317 }); |
318 | 318 |
319 var videoElementInitializePromise; | 319 var videoElementInitializePromise; |
320 if (this.currentCast_) { | 320 if (this.currentCast_) { |
321 metrics.recordUserAction('CastVideo'); | |
Ilya Sherman
2014/12/02 23:45:10
This looks like you're recording a user action rat
yoshiki
2014/12/08 02:52:29
Thanks for guidance. I've changed it to recording
| |
322 | |
321 videoPlayerElement.setAttribute('casting', true); | 323 videoPlayerElement.setAttribute('casting', true); |
322 | 324 |
323 document.querySelector('#cast-name').textContent = | 325 document.querySelector('#cast-name').textContent = |
324 this.currentCast_.friendlyName; | 326 this.currentCast_.friendlyName; |
325 | 327 |
326 videoPlayerElement.setAttribute('castable', true); | 328 videoPlayerElement.setAttribute('castable', true); |
327 | 329 |
328 videoElementInitializePromise = media.isAvailableForCast() | 330 videoElementInitializePromise = media.isAvailableForCast() |
329 .then(function(result) { | 331 .then(function(result) { |
330 if (!result) | 332 if (!result) |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
383 }.wrap()); | 385 }.wrap()); |
384 this.videoElement_.addEventListener('pause', function() { | 386 this.videoElement_.addEventListener('pause', function() { |
385 chrome.power.releaseKeepAwake(); | 387 chrome.power.releaseKeepAwake(); |
386 }.wrap()); | 388 }.wrap()); |
387 | 389 |
388 this.videoElement_.load(); | 390 this.videoElement_.load(); |
389 callback(); | 391 callback(); |
390 }.bind(this)) | 392 }.bind(this)) |
391 // In case of error. | 393 // In case of error. |
392 .catch(function(error) { | 394 .catch(function(error) { |
395 if (this.currentCast_) | |
396 metrics.recordUserAction('CastVideoError'); | |
397 | |
393 videoPlayerElement.removeAttribute('loading'); | 398 videoPlayerElement.removeAttribute('loading'); |
394 console.error('Failed to initialize the video element.', | 399 console.error('Failed to initialize the video element.', |
395 error.stack || error); | 400 error.stack || error); |
396 this.controls_.showErrorMessage( | 401 this.controls_.showErrorMessage( |
397 'VIDEO_PLAYER_VIDEO_FILE_UNSUPPORTED'); | 402 'VIDEO_PLAYER_VIDEO_FILE_UNSUPPORTED'); |
398 callback(); | 403 callback(); |
399 }.bind(this)); | 404 }.bind(this)); |
400 }.wrap(this)); | 405 }.wrap(this)); |
401 }; | 406 }; |
402 | 407 |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
661 }.wrap(null)); | 666 }.wrap(null)); |
662 } | 667 } |
663 | 668 |
664 var initPromise = Promise.all( | 669 var initPromise = Promise.all( |
665 [new Promise(initVideos.wrap(null)), | 670 [new Promise(initVideos.wrap(null)), |
666 new Promise(initStrings.wrap(null)), | 671 new Promise(initStrings.wrap(null)), |
667 new Promise(util.addPageLoadHandler.wrap(null))]); | 672 new Promise(util.addPageLoadHandler.wrap(null))]); |
668 | 673 |
669 initPromise.then(function(results) { | 674 initPromise.then(function(results) { |
670 var videos = results[0]; | 675 var videos = results[0]; |
676 | |
677 metrics.recordUserAction('OpenVideoPlayer'); | |
678 metrics.recordSmallCount('NumberOfOpenedFiles', videos.length); | |
679 | |
671 player.prepare(videos); | 680 player.prepare(videos); |
672 return new Promise(player.playFirstVideo.wrap(player)); | 681 return new Promise(player.playFirstVideo.wrap(player)); |
673 }.wrap(null)); | 682 }.wrap(null)); |
OLD | NEW |