Index: chrome/browser/resources/file_manager/foreground/js/media/audio_player.js |
diff --git a/chrome/browser/resources/file_manager/foreground/js/media/audio_player.js b/chrome/browser/resources/file_manager/foreground/js/media/audio_player.js |
index acb7472d357fb0138e6366808fb748e61092e04f..916c52c471d73b6cb82b3f272fdde7c0504695c8 100644 |
--- a/chrome/browser/resources/file_manager/foreground/js/media/audio_player.js |
+++ b/chrome/browser/resources/file_manager/foreground/js/media/audio_player.js |
@@ -40,7 +40,6 @@ function AudioPlayer(container) { |
this.audioControls_ = new FullWindowAudioControls( |
createChild(), this.advance_.bind(this), this.onError_.bind(this)); |
- |
this.audioControls_.attachMedia(createChild('', 'audio')); |
chrome.fileBrowserPrivate.getStrings(function(strings) { |
@@ -74,7 +73,7 @@ AudioPlayer.load = function() { |
AudioPlayer.instance = |
new AudioPlayer(document.querySelector('.audio-player')); |
- reload(); |
+ AudioPlayer.instance.load(window.appState); |
hirono
2014/01/17 05:12:12
Can we keep the line as reload() since the reload
mtomasz
2014/01/17 05:14:30
What do you mean? Can you clarify, please?
hirono
2014/01/17 05:18:48
This CL replaces "reload()" with "AudioPlayer.inst
mtomasz
2014/01/17 05:27:42
That's right, but I think it is spaghetti to call
hirono
2014/01/17 05:32:27
I got it. Then lgtm!
|
}; |
util.addPageLoadHandler(AudioPlayer.load); |
@@ -91,11 +90,7 @@ function unload() { |
* Reload the player. |
*/ |
function reload() { |
- if (window.appState) { |
- util.saveAppState(); |
- AudioPlayer.instance.load(window.appState); |
- return; |
- } |
+ AudioPlayer.instance.load(window.appState); |
} |
/** |
@@ -107,8 +102,9 @@ AudioPlayer.prototype.load = function(playlist) { |
this.audioControls_.pause(); |
this.currentTrack_ = -1; |
- // Save the app state, in case of restart. |
- window.appState = playlist; |
+ // Save the app state, in case of restart. Make a copy of the object, so the |
+ // playlist member is not changed after entries are resolved. |
+ window.appState = JSON.parse(JSON.stringify(playlist)); |
util.saveAppState(); |
util.URLsToEntries(playlist.items, function(entries) { |
@@ -216,13 +212,9 @@ AudioPlayer.prototype.select_ = function(newTrack, opt_restoreState) { |
this.currentTrack_ = newTrack; |
- if (window.appState) { |
- window.appState.position = this.currentTrack_; |
- window.appState.time = 0; |
- util.saveAppState(); |
- } else { |
- util.platform.setPreference(AudioPlayer.TRACK_KEY, this.currentTrack_); |
- } |
+ window.appState.position = this.currentTrack_; |
+ window.appState.time = 0; |
+ util.saveAppState(); |
this.scrollToCurrent_(false); |