Created
September 4, 2013 14:11
-
-
Save snaselj/6437476 to your computer and use it in GitHub Desktop.
node-dbus PulseAudio problem
This file contains 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
'use strict'; | |
var Dbus = require('node-dbus'); | |
getAddress(); | |
var timeout = setTimeout(function() {}, 1000); | |
function getAddress(path, cb){ | |
var msg = Object.create(Dbus.DBusMessage, { | |
bus: { | |
value: Dbus.DBUS_BUS_SESSION | |
}, | |
destination: { | |
value: 'org.pulseaudio.Server' | |
}, | |
path: { | |
value: '/org/pulseaudio/server_lookup1' | |
}, | |
iface: { | |
value: 'org.freedesktop.DBus.Properties' | |
}, | |
member: { | |
value: 'Get', | |
}, | |
type: { | |
value: Dbus.DBUS_MESSAGE_TYPE_METHOD_RETURN, | |
writable: true | |
}, | |
timeout: { | |
value: 5000 | |
} | |
}); | |
msg.on('error', onError); | |
msg.on('methodResponse', onAddress); | |
msg.appendArgs('ss', 'org.PulseAudio.ServerLookup1', 'Address'); | |
msg.send(); | |
}; | |
function onError(err) { | |
console.log('ERROR', err); | |
} | |
function onAddress(addr) { | |
console.log('PULSE BUS ADDRESS', addr); | |
var msg = Object.create(Dbus.DBusMessage, { | |
address: { | |
value: addr | |
}, | |
destination: { | |
value: '' | |
}, | |
path: { | |
value: '/org/pulseaudio/core1' | |
}, | |
iface: { | |
value: 'org.freedesktop.DBus.Properties' | |
}, | |
member: { | |
value: 'Get', | |
}, | |
type: { | |
value: Dbus.DBUS_MESSAGE_TYPE_METHOD_RETURN, | |
writable: true | |
}, | |
timeout: { | |
value: 5000 | |
} | |
}); | |
msg.on('methodResponse', function(name) { | |
console.log('NAME', name); | |
}); | |
msg.on('error', onError); | |
msg.appendArgs('ss', 'org.PulseAudio.Core1', 'Name'); | |
// Error will be emitted. | |
msg.send(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment