I'm making a Python script to play music through VLC and I wanted to add a way to control audio playback of VLC, like pause/play, next/previous, etc.
I know I can change shuffle mode before launching VLC with the --random and --no-random arguments. However, is there a way to change playback settings through the Linux terminal while VLC is running?
12 Comments
Maxy@lemmy.blahaj.zone · 21 pts · 154d
VLC appears to support MPRIS, so commands like
Should be able to control it. See the Relevant arch wiki page for more info.
VLC also appears to have a TUI interface. Check out the VLC wiki
flameleaf@lemmy.ml · 6 pts · 154d
There's also a CLI interface accessible through
cvlcAstroLightz@lemmy.world · 2 pts · 154d
Thank you so much! One more thing: would there be a way to check if the user has
playerctlinstalled on their system? Or is there a Python package like it?floquant@lemmy.dbzer0.com · 3 pts · 153d
You can test if a command exists in several ways, but the most portable one should be using
command -vwhich is POSIX.Maxy@lemmy.blahaj.zone · 2 pts · 153d
That depends on your distro. On Debian/ubuntu(-based) distro's, you can try
apt list --installed playerctl, which will output nothing if the package isn't yet installed, or the package name with version info if it is installed. To install it, runsudo apt install playerctlOn arch(-based) distro's, you can try
pacman -Qi playerctl, which should return an error if there is no such package installed, or several lines of info if it is installed. To install it, runsudo pacman -S playerctl, ideally after running a full system upgrade withsudo pacman -Syufloquant@lemmy.dbzer0.com · 2 pts · 153d
Testing if the current shell can execute something does not require looking at the installed packages, there are portable ways to do that
felsiq@piefed.zip · 1 pts · 154d
If you don’t want a playerctl dependency you can use a dbus library to check for mpris players manually, though it’s a little less readable
nfms@lemmy.ml · 1 pts · 153d
https://wiki.archlinux.org/title/MPRIS
In section 2.3 it explains how to use D-Bus and I think OP should use it instead
WronglyCommute@programming.dev · 1 pts · 153d
You could always run
whereis playerctland parse the output with awk or sedfloquant@lemmy.dbzer0.com · 3 pts · 153d
whereisis not a Bash built-in so it may itself not be installed, plus it exits 0 and returns output even on no match requiring additional logic/processing.whichorcommandare more robust choices for this usecaseutopiah@lemmy.ml · 2 pts · 153d
I tinker with VLC using and... so far my "trick" is a bit dirty, namely I don't "control" it as much as I
killallpotential running instances then I startcvlcagain with the right parameters. If you want continuity though you might not want that.Note also that if you plan to do scripting check
mpvas it's a bit easier to tinker with IMHO.Check https://pypi.org/project/python-vlc/ then for Python bindings, that should give you the affordances you need.
hkwln@lemmy.ml · 0 pts · 152d
when you use the terminal, why use vlc when you can use ffmpeg?