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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 this.controls.casting = !!this.currentCast_; | 308 this.controls.casting = !!this.currentCast_; |
309 | 309 |
310 videoPlayerElement.setAttribute('loading', true); | 310 videoPlayerElement.setAttribute('loading', true); |
311 | 311 |
312 var media = new MediaManager(video.entry); | 312 var media = new MediaManager(video.entry); |
313 | 313 |
314 Promise.all([media.getThumbnail(), media.getToken()]) | 314 Promise.all([media.getThumbnail(), media.getToken()]) |
315 .then(function(results) { | 315 .then(function(results) { |
316 var url = results[0]; | 316 var url = results[0]; |
317 var token = results[1]; | 317 var token = results[1]; |
318 document.querySelector('#thumbnail').style.backgroundImage = | 318 if (url && token) { |
319 'url(' + url + '&access_token=' + token + ')'; | 319 document.querySelector('#thumbnail').style.backgroundImage = |
| 320 'url(' + url + '&access_token=' + token + ')'; |
| 321 } else { |
| 322 document.querySelector('#thumbnail').style.backgroundImage = ''; |
| 323 } |
320 }) | 324 }) |
321 .catch(function() { | 325 .catch(function() { |
322 // Shows no image on error. | 326 // Shows no image on error. |
323 document.querySelector('#thumbnail').style.backgroundImage = ''; | 327 document.querySelector('#thumbnail').style.backgroundImage = ''; |
324 }); | 328 }); |
325 | 329 |
326 var videoElementInitializePromise; | 330 var videoElementInitializePromise; |
327 if (this.currentCast_) { | 331 if (this.currentCast_) { |
328 videoPlayerElement.setAttribute('casting', true); | 332 videoPlayerElement.setAttribute('casting', true); |
329 | 333 |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 var initPromise = Promise.all( | 671 var initPromise = Promise.all( |
668 [new Promise(initVideos.wrap(null)), | 672 [new Promise(initVideos.wrap(null)), |
669 new Promise(initStrings.wrap(null)), | 673 new Promise(initStrings.wrap(null)), |
670 new Promise(util.addPageLoadHandler.wrap(null))]); | 674 new Promise(util.addPageLoadHandler.wrap(null))]); |
671 | 675 |
672 initPromise.then(function(results) { | 676 initPromise.then(function(results) { |
673 var videos = results[0]; | 677 var videos = results[0]; |
674 player.prepare(videos); | 678 player.prepare(videos); |
675 return new Promise(player.playFirstVideo.wrap(player)); | 679 return new Promise(player.playFirstVideo.wrap(player)); |
676 }.wrap(null)); | 680 }.wrap(null)); |
OLD | NEW |