OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 * The overlay displaying the image. | 6 * The overlay displaying the image. |
7 * @param {HTMLElement} container The container element. | 7 * @param {HTMLElement} container The container element. |
8 * @param {Viewport} viewport The viewport. | 8 * @param {Viewport} viewport The viewport. |
9 * @param {MetadataCache} metadataCache The metadataCache. | 9 * @param {MetadataCache} metadataCache The metadataCache. |
10 */ | 10 */ |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 var loadingVideo = FileType.getMediaType(url) == 'video'; | 321 var loadingVideo = FileType.getMediaType(url) == 'video'; |
322 if (loadingVideo) { | 322 if (loadingVideo) { |
323 var video = this.document_.createElement('video'); | 323 var video = this.document_.createElement('video'); |
324 var videoPreview = !!(metadata.thumbnail && metadata.thumbnail.url); | 324 var videoPreview = !!(metadata.thumbnail && metadata.thumbnail.url); |
325 if (videoPreview) { | 325 if (videoPreview) { |
326 video.setAttribute('poster', metadata.thumbnail.url); | 326 video.setAttribute('poster', metadata.thumbnail.url); |
327 this.replace(video, effect); // Show the poster immediately. | 327 this.replace(video, effect); // Show the poster immediately. |
328 if (displayCallback) displayCallback(); | 328 if (displayCallback) displayCallback(); |
329 } | 329 } |
330 | 330 |
331 function onVideoLoad(error) { | 331 var onVideoLoad = function(error) { |
332 video.removeEventListener('loadedmetadata', onVideoLoadSuccess); | 332 video.removeEventListener('loadedmetadata', onVideoLoadSuccess); |
333 video.removeEventListener('error', onVideoLoadError); | 333 video.removeEventListener('error', onVideoLoadError); |
334 displayMainImage(ImageView.LOAD_TYPE_VIDEO_FILE, videoPreview, video, | 334 displayMainImage(ImageView.LOAD_TYPE_VIDEO_FILE, videoPreview, video, |
335 error); | 335 error); |
336 } | 336 }; |
337 var onVideoLoadError = onVideoLoad.bind(this, 'VIDEO_ERROR'); | 337 var onVideoLoadError = onVideoLoad.bind(this, 'VIDEO_ERROR'); |
338 var onVideoLoadSuccess = onVideoLoad.bind(this, null); | 338 var onVideoLoadSuccess = onVideoLoad.bind(this, null); |
339 | 339 |
340 video.addEventListener('loadedmetadata', onVideoLoadSuccess); | 340 video.addEventListener('loadedmetadata', onVideoLoadSuccess); |
341 video.addEventListener('error', onVideoLoadError); | 341 video.addEventListener('error', onVideoLoadError); |
342 | 342 |
343 // Do not try no stream when offline. | 343 // Do not try no stream when offline. |
344 video.src = (navigator.onLine && metadata.streaming && | 344 video.src = (navigator.onLine && metadata.streaming && |
345 metadata.streaming.url) || url; | 345 metadata.streaming.url) || url; |
346 video.load(); | 346 video.load(); |
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1043 | 1043 |
1044 /** | 1044 /** |
1045 * @param {HTMLCanvasElement|HTMLVideoElement} element Element. | 1045 * @param {HTMLCanvasElement|HTMLVideoElement} element Element. |
1046 * @return {string} Transform string. | 1046 * @return {string} Transform string. |
1047 */ | 1047 */ |
1048 ImageView.Effect.Rotate.prototype.transform = function(element) { | 1048 ImageView.Effect.Rotate.prototype.transform = function(element) { |
1049 var ratio = ImageView.Effect.getPixelRatio_(element); | 1049 var ratio = ImageView.Effect.getPixelRatio_(element); |
1050 return 'rotate(' + (this.rotate90_ * 90) + 'deg) ' + | 1050 return 'rotate(' + (this.rotate90_ * 90) + 'deg) ' + |
1051 'scale(' + (this.scale_ / ratio) + ')'; | 1051 'scale(' + (this.scale_ / ratio) + ')'; |
1052 }; | 1052 }; |
OLD | NEW |