Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: chrome/browser/resources/file_manager/js/media/audio_player.js

Issue 9854015: Handle broken artwork icons in Chrome OS Media Player (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 document.addEventListener('DOMContentLoaded', function() { 5 document.addEventListener('DOMContentLoaded', function() {
6 // Test harness sets the search string to prevent the automatic load. 6 // Test harness sets the search string to prevent the automatic load.
7 // It calls AudioPlayer.load() explicitly after initializing 7 // It calls AudioPlayer.load() explicitly after initializing
8 // the |chrome| variable with an appropriate mock object. 8 // the |chrome| variable with an appropriate mock object.
9 if (!document.location.search) { 9 if (!document.location.search) {
10 AudioPlayer.load(); 10 AudioPlayer.load();
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 this.loadMetadata_(i); 116 this.loadMetadata_(i);
117 } 117 }
118 }; 118 };
119 119
120 AudioPlayer.prototype.loadMetadata_ = function(track) { 120 AudioPlayer.prototype.loadMetadata_ = function(track) {
121 this.fetchMetadata_( 121 this.fetchMetadata_(
122 this.urls_[track], this.displayMetadata_.bind(this, track)); 122 this.urls_[track], this.displayMetadata_.bind(this, track));
123 }; 123 };
124 124
125 AudioPlayer.prototype.displayMetadata_ = function(track, metadata) { 125 AudioPlayer.prototype.displayMetadata_ = function(track, metadata) {
126 if (metadata.thumbnailURL || metadata.error) { 126 this.trackListItems_[track].setMetadata(metadata, this.container_);
127 this.container_.classList.remove('noart'); 127 this.trackStackItems_[track].setMetadata(metadata, this.container_);
128 }
129 this.trackListItems_[track].setMetadata(metadata);
130 this.trackStackItems_[track].setMetadata(metadata);
131 }; 128 };
132 129
133 AudioPlayer.prototype.select_ = function(newTrack) { 130 AudioPlayer.prototype.select_ = function(newTrack) {
134 if (this.currentTrack_ == newTrack) return; 131 if (this.currentTrack_ == newTrack) return;
135 132
136 this.changeSelectionInList_(this.currentTrack_, newTrack); 133 this.changeSelectionInList_(this.currentTrack_, newTrack);
137 this.changeSelectionInStack_(this.currentTrack_, newTrack); 134 this.changeSelectionInStack_(this.currentTrack_, newTrack);
138 135
139 this.currentTrack_ = newTrack; 136 this.currentTrack_ = newTrack;
140 this.scrollToCurrent_(false); 137 this.scrollToCurrent_(false);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 this.advance_(true /* forward */, true /* only if valid */); 236 this.advance_(true /* forward */, true /* only if valid */);
240 }.bind(this), 237 }.bind(this),
241 3000); 238 3000);
242 }; 239 };
243 240
244 AudioPlayer.prototype.cancelAutoAdvance_ = function() { 241 AudioPlayer.prototype.cancelAutoAdvance_ = function() {
245 if (this.autoAdvanceTimer_) { 242 if (this.autoAdvanceTimer_) {
246 clearTimeout(this.autoAdvanceTimer_); 243 clearTimeout(this.autoAdvanceTimer_);
247 this.autoAdvanceTimer_ = null; 244 this.autoAdvanceTimer_ = null;
248 } 245 }
249 } 246 };
250 247
251 AudioPlayer.prototype.onExpandCollapse_ = function() { 248 AudioPlayer.prototype.onExpandCollapse_ = function() {
252 this.container_.classList.toggle('collapsed'); 249 this.container_.classList.toggle('collapsed');
253 this.syncHeight_(); 250 this.syncHeight_();
254 if (!this.isCompact_()) 251 if (!this.isCompact_())
255 this.scrollToCurrent_(true); 252 this.scrollToCurrent_(true);
256 }; 253 };
257 254
258 /* Keep the below constants in sync with the CSS. */ 255 /* Keep the below constants in sync with the CSS. */
259 // TODO(kaznacheev): Set to 30 when the audio player is title-less. 256 // TODO(kaznacheev): Set to 30 when the audio player is title-less.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 var title = this.url_.split('/').pop(); 315 var title = this.url_.split('/').pop();
319 var dotIndex = title.lastIndexOf('.'); 316 var dotIndex = title.lastIndexOf('.');
320 if (dotIndex >= 0) title = title.substr(0, dotIndex); 317 if (dotIndex >= 0) title = title.substr(0, dotIndex);
321 return title; 318 return title;
322 }; 319 };
323 320
324 AudioPlayer.TrackInfo.prototype.getDefaultArtist = function() { 321 AudioPlayer.TrackInfo.prototype.getDefaultArtist = function() {
325 return 'Unknown Artist'; // TODO(kaznacheev): i18n 322 return 'Unknown Artist'; // TODO(kaznacheev): i18n
326 }; 323 };
327 324
328 AudioPlayer.TrackInfo.prototype.setMetadata = function(metadata) { 325 /**
326 * @param {Object} metadata The metadata object
327 * @param {HTMLElement} container The container for the tracks.
328 */
329 AudioPlayer.TrackInfo.prototype.setMetadata = function(metadata, container) {
329 if (metadata.error) { 330 if (metadata.error) {
330 this.art_.classList.add('blank'); 331 this.art_.classList.add('blank');
331 this.art_.classList.add('error'); 332 this.art_.classList.add('error');
333 container.classList.remove('noart');
332 } else if (metadata.thumbnailURL) { 334 } else if (metadata.thumbnailURL) {
333 this.art_.classList.remove('blank'); 335 this.img_.onload = function() {
336 // Only display the image if the thumbnail
dgozman 2012/03/26 10:52:49 Incomplete phrase?
Vladislav Kaznacheev 2012/03/26 10:55:52 Done.
337 this.art_.classList.remove('blank');
338 container.classList.remove('noart');
339 }.bind(this);
334 this.img_.src = metadata.thumbnailURL; 340 this.img_.src = metadata.thumbnailURL;
335 } 341 }
336 this.title_.textContent = metadata.title || this.getDefaultTitle(); 342 this.title_.textContent = metadata.title || this.getDefaultTitle();
337 this.artist_.textContent = metadata.artist || this.getDefaultArtist(); 343 this.artist_.textContent = metadata.artist || this.getDefaultArtist();
338 }; 344 };
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698