From d2bbca5e0182b0f984c5fb4398ef3088bb794b63 Mon Sep 17 00:00:00 2001 From: Steve Labus Date: Sun, 18 Mar 2018 20:09:30 +0100 Subject: [PATCH] 0.4.0 --- README.md | 24 ++++++++++++++++++------ example.js | 1 + package-lock.json | 2 +- package.json | 4 ++-- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index ca219e2..e01fc99 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # iTunes-bridge -A macOS only NodeJS package to control and get informations from iTunes through AppleScript +A macOS and Windows NodeJS package to control and get informations from iTunes through AppleScript + +#### If you need OS X Mavericks and earlier support, use the 0.3.0-alpha. No Windows support and events in this version. ### This package is a WIP, a lot of functions will be added in the future and some that are already existing could change # Documentation @@ -7,7 +9,6 @@ No documentation yet, but you can look at the code of [iTunes-Discord integratio There is also an example.js that you can run. ```js - var iTunes = require('./itunes-bridge'); var currentTrack = iTunes.getCurrentTrack(); // We load the iTunes-bridge emitter to receive events @@ -34,14 +35,25 @@ switch(currentTrack.playerState){ }; // Do something when iTunes is playing -iTunesEmitter.on('playing', function(message){ - console.log(message.name+" is now playing!"); +iTunesEmitter.on('playing', function(type, currentTrack){ + // If it is a paused track that restarts playing + if(type === "player_state_change") { + console.log(currentTrack.name + " has been resumed! "); + // Or if it is a new track + }else if(type === 'new_track'){ + console.log(currentTrack.name+" is now playing!") + } }); // Do something when iTunes is paused -iTunesEmitter.on('paused', function(message){ - console.log(message.name+" is now paused!"); +iTunesEmitter.on('paused', function(type, currentTrack){ + console.log(currentTrack.name+" is now paused!"); }); +// Do something when iTunes is stopped +iTunesEmitter.on('stopped', function(){ + console.log("iTunes is not longer playing!"); +}); + ``` \ No newline at end of file diff --git a/example.js b/example.js index 94e1324..41fb9e2 100644 --- a/example.js +++ b/example.js @@ -41,6 +41,7 @@ iTunesEmitter.on('playing', function(type, currentTrack){ iTunesEmitter.on('paused', function(type, currentTrack){ console.log(currentTrack.name+" is now paused!"); }); +// Do something when iTunes is stopped iTunesEmitter.on('stopped', function(){ console.log("iTunes is not longer playing!"); }); diff --git a/package-lock.json b/package-lock.json index 48517df..3cfcbc3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "itunes-bridge", - "version": "0.3.0", + "version": "0.4.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index a2716f4..2aa3f2d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "itunes-bridge", - "version": "0.3.0", - "description": "A macOS only (for the moment) NodeJS package to control and get informations from iTunes through AppleScript", + "version": "0.4.0", + "description": "A macOS and Windows NodeJS package to control and get informations from iTunes through AppleScript", "main": "itunes-bridge.js", "repository": { "type": "git",