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

Unified Diff: chrome/browser/resources/file_manager/foreground/js/media/audio_player.js

Issue 141273004: Play automatically when reloading the audio player with new songs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 | chrome/browser/resources/file_manager/foreground/js/media/media_controls.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/foreground/js/media/media_controls.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698