DBus-usage

From VideoLAN Wiki
Revision as of 13:19, 13 September 2012 by Lausbub (talk | contribs)
Jump to navigation Jump to search

The following is a usage example of how to control VLC though DBUS, by simple using dbus-send. This bash script toggles between Play/Pause:

Stopped -> Play

Playing -> Pause

Pause -> Play

#!/bin/bash
if [ -z `dbus-send --print-reply --session --dest=org.mpris.vlc /Player org.freedesktop.MediaPlayer.GetStatus | grep "int32 2"` ]; then
        dbus-send --print-reply --session --dest=org.mpris.vlc /Player org.freedesktop.MediaPlayer.Pause
else
    	dbus-send --print-reply --session --dest=org.mpris.vlc /Player org.freedesktop.MediaPlayer.Play
fi

If you have qt-dbus (or libqt4-dev) installed, you can also use qdbus to toggle between Play/Pause

#!/bin/bash
qdbus org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause

See also