Skip to content
Advertisement

Linux Shell: VLC programming

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.

Advertisement

Answer

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.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement