Skip to content

Commit

Permalink
playerState of getCurrentTrack() can now return stopped or not running
Browse files Browse the repository at this point in the history
  • Loading branch information
AngryKiller committed Mar 11, 2018
1 parent 64c0b12 commit 9e4dc94
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
19 changes: 13 additions & 6 deletions itunes-bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,21 @@ var path = require('path');
var scptsPath = path.join(__dirname, "./applescript/");

exports.getCurrentTrack = function() {
var scpt = scptsPath+'getCurrentTrack.applescript';
try{
return JSON.parse(applescript.noExecSync(scpt));
}catch(err){
return null;
var scpt = scptsPath + 'getCurrentTrack.applescript';
if (isAppRunning("iTunes")) {
try {
return JSON.parse(applescript.noExecSync(scpt));
} catch (err) {
var playerState = {"playerState": "stopped"};
return playerState;
}
}
else{
var playerState = {"playerState": "not running"};
return playerState;
}
}

};

exports.getPlayerState = function() {
if(isAppRunning("iTunes")) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "itunes-bridge",
"version": "0.2.1",
"version": "0.2.2",
"description": "A NodeJS package to control and get informations from iTunes through AppleScript",
"main": "itunes-bridge.js",
"repository": {
Expand Down

0 comments on commit 9e4dc94

Please sign in to comment.