Skip to content

Instantly share code, notes, and snippets.

@snaselj
Last active December 16, 2015 18:50
Show Gist options
  • Save snaselj/5481155 to your computer and use it in GitHub Desktop.
Save snaselj/5481155 to your computer and use it in GitHub Desktop.
Problem with reading metadata from VLC over D-Bus with nodejs and dbus-native.
'use strict';
// Before starting this script run VLC:
// vlc --control dbus http://212.96.160.160:7978/listen.pls
var Dbus = require('dbus-native');
var bus = Dbus.sessionBus();
// Works
bus.invoke({
destination: 'org.mpris.MediaPlayer2.vlc',
// destination: 'org.mpris.MediaPlayer2.vlc-' + <pid>, // VLC sometimes opens only a connection with its PID in its name.
path: '/org/mpris/MediaPlayer2',
'interface': 'org.freedesktop.DBus.Properties',
member: 'Get',
signature: 'ss',
body: [
'org.mpris.MediaPlayer2.Player',
'PlaybackStatus'
]
}, function(err, data) {
if (err) console.log('ERROR PlaybackStatus: ', err);
else console.log('RESPONSE PlaybackStatus: ', JSON.stringify(data, null, 2));
});
// Doesn't work
bus.invoke({
destination: 'org.mpris.MediaPlayer2.vlc',
// destination: 'org.mpris.MediaPlayer2.vlc-' + <pid>, // VLC sometimes opens only a connection with its PID in its name.
path: '/org/mpris/MediaPlayer2',
'interface': 'org.freedesktop.DBus.Properties',
member: 'Get',
signature: 'ss',
body: [
'org.mpris.MediaPlayer2.Player',
'Metadata'
]
}, function(err, data) {
if (err) console.log('ERROR Metadata: ', err);
else console.log('RESPONSE: Metadata', JSON.stringify(data, null, 2));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment