Linux control a running vlc process through command line

妖精的绣舞 提交于 2019-11-30 17:08:04

问题


is there any way to control an already running VLC player on ubuntu. For example, i am trying to start a vlc video full screen with a default audio.

and then control the volume and other features through netcat or some other command remotely. is it possible?


回答1:


Have you looked at the rc (remote control) interface ? It controls a VLC process via a Unix Domain Socket. See here and here for more info.




回答2:


The script player control from exic's answer is just a wrapper for some dbus commands. To use them without the script, try the following:

dbus-send --type=method_call --dest=org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause

The last PlayPause can be replaced with, e.g., Play, Pause, Previous, Next.

If you have qdbus installed, it can be used as an alternative to dbus-send:

qdbus org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause

A list of all available calls can be obtained by leaving out the last argument:

qdbus org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2



回答3:


If you enable the HTTP remote interface on VLC, you can control VLC remotely with a web browser, or even an app on your phone.

With the HTTP interface enabled, you can also use wget or curl commands to send commands.

For example, enable VLC's HTTP interface (default port: 8080) with "password" for a password. Then you can issue curl commands, either remotely or locally:

To pause:

curl -s -o /dev/null -u :password http://192.168.1.11:8080/requests/status.xml?command=pl_pause

To play:

curl -s -o /dev/null -u :password http://192.168.1.11:8080/requests/status.xml?command=pl_play

To play a specific playlist entry number:

curl -s -o /dev/null -u :password http://192.168.1.11:8080/requests/status.xml?command=pl_play&id=22

To change volume:

curl -s -o /dev/null -u :password http://192.168.1.11:8080/requests/status.xml?command=volume&val=133

Other command info: https://wiki.videolan.org/VLC_HTTP_requests/




回答4:


I'm controlling it remotely using dbus. VLC has implemented the MPRIS2 specification:

  • Control player (e. g. run player-control vlc toggle)

  • Get current status (with argument vlc)



来源:https://stackoverflow.com/questions/14256193/linux-control-a-running-vlc-process-through-command-line

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!