Thursday, June 8, 2017

control or send key strok to mpv through command line

1- run mpv with the following command to create its socket in /tmp/mpvsocket
$ mpv --shuffle videoOrAudioFiles --input-ipc-server=/tmp/mpvsocket

2- to lower the volume
$ echo '{"command":["keypress", "volume_down"]}' | socat - /tmp/mpvsocket

- play next file
$ echo '{"command":["keypress", "enter"]}' | socat - /tmp/mpvsocket

- pause
$ echo '{"command":["keypress", "p"]}' | socat - /tmp/mpvsocket

or

$ echo '{"command":["keypress", "space"]}' | socat - /tmp/mpvsocket 

3- to get the complete list of all available keys
$ mpv --input-keylist


4- other method, we can control mpv with property
- to pause
$ echo '{ "command": ["set_property", "pause", true] }' | socat - /tmp/mpvsocket 

- to get the complete list of properties
$ mpv --list-properties

No comments:

Post a Comment