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

Unified Diff: chrome/browser/resources/file_manager/foreground/js/media/media_controls.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
Index: chrome/browser/resources/file_manager/foreground/js/media/media_controls.js
diff --git a/chrome/browser/resources/file_manager/foreground/js/media/media_controls.js b/chrome/browser/resources/file_manager/foreground/js/media/media_controls.js
index a335bdc4c525294338951c4eee057c22e2073033..174796c486af6affa1074152693253a9fdf4ebf8 100644
--- a/chrome/browser/resources/file_manager/foreground/js/media/media_controls.js
+++ b/chrome/browser/resources/file_manager/foreground/js/media/media_controls.js
@@ -490,21 +490,9 @@ MediaControls.prototype.encodeState = function() {
if (!this.media_.duration)
return;
- if (window.appState) {
- window.appState.time = this.media_.currentTime;
- util.saveAppState();
- return;
- }
-
- var playState = JSON.stringify({
- play: this.isPlaying(),
- time: this.media_.currentTime
- });
-
- var newLocation = document.location.origin + document.location.pathname +
- document.location.search + '#' + playState;
-
- document.location.href = newLocation;
+ window.appState.time = this.media_.currentTime;
+ util.saveAppState();
+ return;
};
/**
@@ -512,53 +500,23 @@ MediaControls.prototype.encodeState = function() {
* @return {boolean} True if decode succeeded.
*/
MediaControls.prototype.decodeState = function() {
- if (window.appState) {
- if (!('time' in window.appState))
- return false;
- // There is no page reload for apps v2, only app restart.
- // Always restart in paused state.
- this.media_.currentTime = appState.time;
- this.pause();
- return true;
- }
-
- var hash = document.location.hash.substring(1);
- if (hash) {
- try {
- var playState = JSON.parse(hash);
- if (!('time' in playState))
- return false;
-
- this.media_.currentTime = playState.time;
-
- if (playState.play)
- this.play();
- else
- this.pause();
-
- return true;
- } catch (e) {
- console.warn('Cannot decode play state');
- }
- }
- return false;
+ if (!('time' in window.appState))
+ return false;
+ // There is no page reload for apps v2, only app restart.
+ // Always restart in paused state.
+ this.media_.currentTime = appState.time;
+ this.pause();
+ return true;
};
/**
* Remove current state from the page URL or the app state.
*/
MediaControls.prototype.clearState = function() {
- if (window.appState) {
- if ('time' in window.appState)
- delete window.appState.time;
- util.saveAppState();
- return;
- }
-
- var newLocation = document.location.origin + document.location.pathname +
- document.location.search + '#';
-
- document.location.href = newLocation;
+ if ('time' in window.appState)
+ delete window.appState.time;
+ util.saveAppState();
+ return;
};
/**

Powered by Google App Engine
This is Rietveld 408576698