如何从命令行暂停 VLC

How to pause VLC from the command line

我使用 i3wm 作为我的 window 管理器,我想添加绑定到 play/pause、next、prev 和停止 VLC。但是,与 MPV 不同,当 VLC 进程已经在外部 运行 时,VLC 没有内置的 CLI 控件。

我发现 this lovely Reddit comment 比 play/pause 更需要回答,并且通过反复试验我发现如何 stop/prev 和下一个:

bindsym XF86AudioNext exec dbus-send --type=method_call \
        --dest=org.mpris.MediaPlayer2.vlc \
        /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next

bindsym XF86AudioPrev exec dbus-send --type=method_call \
        --dest=org.mpris.MediaPlayer2.vlc \
        /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous

bindsym XF86AudioPlay exec dbus-send --type=method_call \
        --dest=org.mpris.MediaPlayer2.vlc \
        /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause

bindsym XF86AudioStop exec dbus-send --type=method_call \
        --dest=org.mpris.MediaPlayer2.vlc \
        /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Stop

编辑:像 Antoine 提到的那样使用 playerctl 使这更直接:

bindsym XF86AudioNext exec playerctl next

bindsym XF86AudioPrev exec playerctl previous

bindsym XF86AudioPlay exec playerctl play

bindsym XF86AudioStop exec playerctl pause

安装 playerctl 可以吗?

我正在使用 playerctl 来控制任何播放设置

# Media player controls
bindsym XF86AudioPlay exec playerctl play-pause
#bindsym XF86AudioPause exec playerctl pause
bindsym XF86AudioNext exec playerctl next
bindsym XF86AudioPrev exec playerctl previous

但是,如果两个应用程序同时使用音频,哪一个会响应 playerctl,则未知。