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

Unified Diff: ui/file_manager/video_player/js/media_controls.js

Issue 2535713003: Remember the last volume level in Video Player. (Closed)
Patch Set: Use lowerCamelCase for local variable. Created 4 years, 1 month 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: ui/file_manager/video_player/js/media_controls.js
diff --git a/ui/file_manager/video_player/js/media_controls.js b/ui/file_manager/video_player/js/media_controls.js
index a2b44eb160d9e17ab3ce523e4c8e10ae94bce0ca..346ddcd839f9672d0c0c756ad3a0dc42b9dd620a 100644
--- a/ui/file_manager/video_player/js/media_controls.js
+++ b/ui/file_manager/video_player/js/media_controls.js
@@ -489,6 +489,11 @@ MediaControls.prototype.updateTimeLabel_ = function(current, opt_duration) {
* Volume controls
*/
+MediaControls.STORAGE_PREFIX = 'videoplayer-';
+
+MediaControls.KEY_NORMALIZED_VOLUME =
+ MediaControls.STORAGE_PREFIX + 'normalized-volume';
+
/**
* @param {HTMLElement=} opt_parent Parent element for the controls.
*/
@@ -512,10 +517,26 @@ MediaControls.prototype.initVolumeControls = function(opt_parent) {
this.volume_.addEventListener('immediate-value-change', function(event) {
this.onVolumeDrag_();
}.bind(this));
- this.volume_.value = this.volume_.max;
+ this.loadVolumeControlState();
volumeControls.appendChild(this.volume_);
};
+MediaControls.prototype.loadVolumeControlState = function() {
+ chrome.storage.local.get([MediaControls.KEY_NORMALIZED_VOLUME],
+ function(retrieved) {
+ var normalizedVolume = (MediaControls.KEY_NORMALIZED_VOLUME
+ in retrieved)
+ ? retrieved[MediaControls.KEY_NORMALIZED_VOLUME] : 1;
+ this.volume_.value = this.volume_.max * normalizedVolume;
+ }.bind(this));
+};
+
+MediaControls.prototype.saveVolumeControlState = function() {
+ var valuesToStore = {};
+ valuesToStore[MediaControls.KEY_NORMALIZED_VOLUME] = this.media_.volume;
+ chrome.storage.local.set(valuesToStore);
+};
+
/**
* Click handler for the sound level button.
* @private
@@ -559,6 +580,7 @@ MediaControls.prototype.onVolumeChange_ = function(value) {
this.soundButton_.setAttribute('aria-label',
value === 0 ? str('MEDIA_PLAYER_UNMUTE_BUTTON_LABEL')
: str('MEDIA_PLAYER_MUTE_BUTTON_LABEL'));
+ this.saveVolumeControlState();
};
/**
« 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