Last active
December 16, 2015 18:19
-
-
Save black--cat/5476340 to your computer and use it in GitHub Desktop.
better solution? I want to observe the playlist for changes. how would i do this without setinterval? In my opinion the best way is to wait for the IPC socket if something happened. Is this possible?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var xmmsclient = require('xmmsclient'), | |
util = require('util') | |
var client = new xmmsclient.Client('blackcat'); | |
client.onconnect = function () { | |
console.log("Connected!") | |
var oldID | |
setInterval(function () { | |
client.playback.current_id().onvalue = function (id) { | |
if (!oldID || oldID !== id) { | |
client.medialib.get_info(id).onvalue = function (propdict) { | |
metadata = xmmsclient.PropDict.flatten(propdict) | |
console.log("Currently playing " + metadata.artist + " - " + metadata.title) | |
} | |
oldID = id | |
} | |
} | |
}, 1000) | |
} | |
client.ondisconnect = function () { | |
console.log("Disconnected!") | |
} | |
client.connect("unix:///tmp/xmms-ipc-blackcat") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment