Skip to content

Commit

Permalink
Added setVolume (windows only)
Browse files Browse the repository at this point in the history
Implemented setVolume for windows (As I don't own a Mac I can't really
update the OSX part).
Introduced 'property', which allows commands to carry a property
separated by a space character.
Removed unnecessary 'result'-variable and fixed a typo.
  • Loading branch information
Florian Wendelborn committed Jan 25, 2015
1 parent c48302a commit 4bd1823
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,8 @@ Playback.prototype.fadeIn = function(callback) {
this.runTransportScript('fadein', callback);
};

Playback.prototype.setVolume = function(volume, callback) {
this.runTransportScript('setvolume ' + volume, callback);
};

module.exports = new Playback();
12 changes: 9 additions & 3 deletions windows_scripts/iTunes.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var isRunning = function() {
};

var getCurrentTrack = function() {
var result, currentTrack ;
var currentTrack;
if (isPlaying()) {
currentTrack = iTunes.CurrentTrack;
return JSON.stringify({
Expand Down Expand Up @@ -97,13 +97,19 @@ var commands = {
};
}
return JSON.stringify({ok: true});
},
setvolume: function(volume) {
iTunes.SoundVolume = volume;
}
};

var command = WScript.Arguments.Item(0);
var args = WScript.Arguments.Item(0).split(' ');
var command = args[0];
var property = args[1] || null;


if (commands[command]) {
WScript.echo(commands[command]());
WScript.echo(commands[command](property));
} else {
WScript.echo(JSON.stringify({error: "Unsupported command"}));
}

0 comments on commit 4bd1823

Please sign in to comment.