mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-22 09:37:17 +00:00
Abstract updating volume
This commit is contained in:
parent
aa7f2ec362
commit
b9072bc97c
2 changed files with 10 additions and 3 deletions
|
|
@ -196,6 +196,7 @@ MainWindow = {
|
|||
window.addEventListener('changeState', function() { self.changeState(); });
|
||||
window.addEventListener('titleUpdated', function() { self.updateTitle(); });
|
||||
window.addEventListener('channelCountUpdated', function() { self.updateChannelCount(); });
|
||||
window.addEventListener('volumeChanged', function() { self.updateVolume(); });
|
||||
|
||||
this.nodes.window.addEventListener('dragenter', this.dragenter.bind(this));
|
||||
this.nodes.window.addEventListener('dragover', this.dragover.bind(this));
|
||||
|
|
@ -290,7 +291,8 @@ MainWindow = {
|
|||
this.updateTime();
|
||||
},
|
||||
|
||||
setVolume: function(volume) {
|
||||
updateVolume: function() {
|
||||
var volume = this.winamp.getVolume();
|
||||
var percent = volume / 100;
|
||||
var sprite = Math.round(percent * 28);
|
||||
var offset = (sprite - 1) * 15;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,8 @@ Winamp = {
|
|||
toggleTimeMode: new Event('toggleTimeMode'),
|
||||
changeState: new Event('changeState'),
|
||||
titleUpdated: new Event('titleUpdated'),
|
||||
channelCountUpdated: new Event('channelCountUpdated')
|
||||
channelCountUpdated: new Event('channelCountUpdated'),
|
||||
volumeChanged: new Event('volumeChanged')
|
||||
}
|
||||
|
||||
this.setVolume(options.volume);
|
||||
|
|
@ -97,6 +98,10 @@ Winamp = {
|
|||
return this.media.channels();
|
||||
},
|
||||
|
||||
getVolume: function() {
|
||||
return Math.round(this.media.getVolume() * 100);
|
||||
},
|
||||
|
||||
seekToPercentComplete: function(percent) {
|
||||
this.media.seekToPercentComplete(percent);
|
||||
},
|
||||
|
|
@ -147,7 +152,7 @@ Winamp = {
|
|||
var percent = volume / 100;
|
||||
|
||||
this.media.setVolume(percent);
|
||||
this.mainWindow.setVolume(volume);
|
||||
window.dispatchEvent(this.events.volumeChanged);
|
||||
},
|
||||
|
||||
incrementVolumeBy: function(ammount) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue