Linux Shell: VLC programming

Willem Van Onsem picture Willem Van Onsem · Jan 20, 2012 · Viewed 7.8k times · Source

Is there a way to manipulate VLC with a Linux shell script without the script waiting for VLC to close.

cvlc test.mp3
echo "Now playing!"
sleep 200
cvlc://pause:60

This code keeps running VLC until the file is completed, and then evidently it is to late to pause the file.

Answer

Abhijeet Rastogi picture Abhijeet Rastogi · Jan 28, 2012

You need to use dbus interface of VLC.

enter image description here

Now, you can use the mpris interface of VLC. It's a standard for most players like clementine, banshee, songbird, spotify etc.

So, lets suppose you want to Pause the currently playing song.

dbus-send --print-reply --session --dest=org.mpris.vlc /Player org.freedesktop.MediaPlayer.Pause

To play a song:

dbus-send --print-reply --session --dest=org.mpris.vlc /Player org.freedesktop.MediaPlayer.Play

I generally use qdbusviewer to know about the dbus-interface available to me.