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

Unified 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: Addressed a comment 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/file_manager/js/media/audio_player.js
diff --git a/chrome/browser/resources/file_manager/js/media/audio_player.js b/chrome/browser/resources/file_manager/js/media/audio_player.js
index 78dff06b9db63eb6ee4fc18324abeeaf1124caae..aa86a26d6be1732a11a291e08a6a490cb1f5e8f8 100644
--- a/chrome/browser/resources/file_manager/js/media/audio_player.js
+++ b/chrome/browser/resources/file_manager/js/media/audio_player.js
@@ -123,11 +123,8 @@ AudioPlayer.prototype.loadMetadata_ = function(track) {
};
AudioPlayer.prototype.displayMetadata_ = function(track, metadata) {
- if (metadata.thumbnailURL || metadata.error) {
- this.container_.classList.remove('noart');
- }
- this.trackListItems_[track].setMetadata(metadata);
- this.trackStackItems_[track].setMetadata(metadata);
+ this.trackListItems_[track].setMetadata(metadata, this.container_);
+ this.trackStackItems_[track].setMetadata(metadata, this.container_);
};
AudioPlayer.prototype.select_ = function(newTrack) {
@@ -246,7 +243,7 @@ AudioPlayer.prototype.cancelAutoAdvance_ = function() {
clearTimeout(this.autoAdvanceTimer_);
this.autoAdvanceTimer_ = null;
}
-}
+};
AudioPlayer.prototype.onExpandCollapse_ = function() {
this.container_.classList.toggle('collapsed');
@@ -325,12 +322,21 @@ AudioPlayer.TrackInfo.prototype.getDefaultArtist = function() {
return 'Unknown Artist'; // TODO(kaznacheev): i18n
};
-AudioPlayer.TrackInfo.prototype.setMetadata = function(metadata) {
+/**
+ * @param {Object} metadata The metadata object
+ * @param {HTMLElement} container The container for the tracks.
+ */
+AudioPlayer.TrackInfo.prototype.setMetadata = function(metadata, container) {
if (metadata.error) {
this.art_.classList.add('blank');
this.art_.classList.add('error');
+ container.classList.remove('noart');
} else if (metadata.thumbnailURL) {
- this.art_.classList.remove('blank');
+ this.img_.onload = function() {
+ // Only display the image if the thumbnail loaded successfully.
+ this.art_.classList.remove('blank');
+ container.classList.remove('noart');
+ }.bind(this);
this.img_.src = metadata.thumbnailURL;
}
this.title_.textContent = metadata.title || this.getDefaultTitle();
« 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