Skip to content

Instantly share code, notes, and snippets.

@tallica
Created May 13, 2012 15:32
Show Gist options
  • Save tallica/2688942 to your computer and use it in GitHub Desktop.
Save tallica/2688942 to your computer and use it in GitHub Desktop.
Audacious nodejs
dbus = require 'node-dbus'
class Audacious
common_msg = (memb, cb) ->
cb Object.create dbus.DBusMessage,
destination:
value: 'org.atheme.audacious'
path:
value: '/org/atheme/audacious'
iface:
value: 'org.atheme.audacious'
member:
value: memb
writable: true
bus:
value: dbus.DBUS_BUS_SESSION
type:
value: dbus.DBUS_MESSAGE_TYPE_METHOD_CALL
writable: true
sender:
value: 'audacious.webui'
@call: (memb, callb) ->
common_msg memb, (msg) ->
msg.on 'methodResponse', (arg) ->
console.log "[PASSED] Got method response with data ::"
console.log arguments
callb arguments if callb
msg.on 'error', (error) ->
console.log "[FAILED] ERROR -- "
console.log error
callb {}, "An error: #{error}" if callb
msg.send()
@Play: ->
@call 'Play'
@Pause: ->
@call 'Pause'
@Stop: ->
@call 'Stop'
@isPlaying: (callb) ->
@call 'Playing', callb
Audacious.Play()
Audacious.isPlaying (result, err) ->
if result[0]
console.log 'Audacious is playing.'
else
console.log 'Audacious is not playing.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment