Abstract setBalance

This commit is contained in:
Jordan Eldredge 2015-01-31 14:00:09 -08:00
parent 6d95be3612
commit acf5759021
3 changed files with 15 additions and 2 deletions

View file

@ -197,6 +197,7 @@ MainWindow = {
window.addEventListener('titleUpdated', function() { self.updateTitle(); });
window.addEventListener('channelCountUpdated', function() { self.updateChannelCount(); });
window.addEventListener('volumeChanged', function() { self.updateVolume(); });
window.addEventListener('balanceChanged', function() { self.setBalance(); });
window.addEventListener('doubledModeToggled', function() { self.toggleDoubledMode(); });
this.nodes.window.addEventListener('dragenter', this.dragenter.bind(this));
@ -307,7 +308,8 @@ MainWindow = {
this.nodes.volume.value = volume;
},
setBalance: function(balance) {
setBalance: function() {
var balance = this.winamp.getBalance();
var string = '';
if(balance == 0) {
string = 'Balance: Center';

View file

@ -12,6 +12,7 @@ Media = {
},
_startTime: 0,
_position: 0,
_balance: 0,
_playing: false,
_loop: false,
autoPlay: false,
@ -200,6 +201,11 @@ Media = {
this._leftGain.gain.value = 1;
this._rightGain.gain.value = 1;
}
this._balance = balance;
},
getBalance: function() {
return this._balance;
},
toggleRepeat: function() {

View file

@ -23,6 +23,7 @@ Winamp = {
titleUpdated: new Event('titleUpdated'),
channelCountUpdated: new Event('channelCountUpdated'),
volumeChanged: new Event('volumeChanged'),
balanceChanged: new Event('balanceChanged'),
doubledModeToggled: new Event('doubledModeToggled'),
}
@ -167,7 +168,11 @@ Winamp = {
// From -100 to 100
setBalance: function(balance) {
this.media.setBalance(balance);
this.mainWindow.setBalance(balance);
window.dispatchEvent(this.events.balanceChanged);
},
getBalance: function() {
return this.media.getBalance();
},
seekForwardBy: function(seconds) {