nowplaying
Advanced tools
Comparing version 1.0.6 to 1.1.0
#!/usr/bin/env node | ||
var nowplaying = require("./index.js"); | ||
var format = (data) => { | ||
return `[${data.artist} - ${data.name}]`; | ||
} | ||
var time = () => new Date().toTimeString(); | ||
nowplaying.on("playing", function (data) { | ||
console.log("PLAYING!", data); | ||
console.log("PLAYING!", format(data), time()); | ||
}); | ||
nowplaying.on("paused", function (data) { | ||
console.log("PAUSED!", data); | ||
}); | ||
console.log("PAUSED!", format(data), time()); | ||
}); |
@@ -9,3 +9,2 @@ #!/usr/bin/env node | ||
this.init(); | ||
this.lastEventData = ""; | ||
}; | ||
@@ -20,11 +19,5 @@ | ||
var events = utf8string.replace(/}{/g, "}\0{").split("\0"); | ||
events.forEach(function (eventJSON, i) { | ||
var eventData = JSON.parse(eventJSON); | ||
//Dedupe, as Rdio emits duplicate playing or paused events in some cases | ||
if (JSON.stringify(instance.lastEventData) != JSON.stringify(eventData)) { | ||
instance.emit(eventData.playerState.toLowerCase(), eventData); | ||
instance.lastEventData = eventData; | ||
} | ||
instance.emit(eventData.playerState.toLowerCase(), eventData); | ||
}) | ||
@@ -31,0 +24,0 @@ |
{ | ||
"name": "nowplaying", | ||
"version": "1.0.6", | ||
"version": "1.1.0", | ||
"description": "Simple node JS event emitter for iTunes/Spotify/Rdio playing/paused events. Wraps Ruby EventMachine Distributed Notification. Mac only.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
6109
84