4

I use i3wm as my window manager and I want to add a binding to play/pause, next, prev and stop VLC. However, unlike MPV, VLC doesn't have built-in CLI control when the VLC process is already running externally.

Samuel Prevost
  • 1,047
  • 1
  • 11
  • 30

3 Answers3

7

I found this lovely Reddit comment answering than need for play/pause, and through trial and error I found how to also stop/prev and next:

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

EDIT: Using playerctl like Antoine mentionned makes this more straightforward:

bindsym XF86AudioNext exec playerctl next

bindsym XF86AudioPrev exec playerctl previous

bindsym XF86AudioPlay exec playerctl play

bindsym XF86AudioStop exec playerctl pause
Samuel Prevost
  • 1,047
  • 1
  • 11
  • 30
4

Would installing playerctl work, alternatively?

Antoine
  • 166
  • 6
  • This is even better than my solution ! Playerctl is labelled as *"For players supporting the MPRIS D-Bus specification"*, which includes Spotify and VLC afaik. It works flawlessly and if far less barbaric than `dbus-send` lol. Though looking at the dbus syntax, playerctl is essetially doing the same thing as what I did. I will use playerctl instead, thank you :D – Samuel Prevost Dec 23 '20 at 16:55
  • ``playerctl`` seems to be a fine tool, however it's not available on Windows. Is there an alternative for this OS? – Sempervivum Jul 09 '22 at 05:51
2

I'm using playerctl for controlling any playback settings

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

But, if two applications are using audio at the same time, which one will respond to playerctl, is unknown.

chinmay_manas
  • 86
  • 1
  • 4