Advertisement
metalx1000

MPV remote socket commands for script control and server use

Nov 26th, 2017
1,551
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.56 KB | None | 0 0
  1. #MPV remote control shell commands
  2. #set things up by installing needed programs
  3. sudo apt install mpv youtube-dl socat
  4.  
  5. #start service and create file to write to
  6. mpv --idle --input-ipc-server=/tmp/mpvsocket
  7.  
  8. #load file
  9. #this example is playing a youtube video so youtube-dl is needed
  10. echo loadfile "https://www.youtube.com/watch?v=JSiLviAsX6M"|socat - /tmp/mpvsocket
  11.  
  12. #or if you want json response you can use json to run commands
  13. echo '{ "command": ["loadfile", "https://www.youtube.com/watch?v=HeeE1XIxHzg"] }'| socat - /tmp/mpvsocket
  14.  
  15. #Pause file
  16. echo '{ "command": ["set_property", "pause", true] }'| socat - /tmp/mpvsocket
  17.  
  18. #unpause file
  19. echo '{ "command": ["set_property", "pause", false] }'| socat - /tmp/mpvsocket
  20.  
  21. #to append another file to the end of the playlist
  22. echo loadfile "https://www.youtube.com/watch?v=Gzn396wr9AY" append-play |socat - /tmp/mpvsocket
  23.  
  24. #seek forward and back in seconds
  25. echo '{ "command": [ "seek", "+1" ] }' | socat - /tmp/mpvsocket
  26. echo '{ "command": [ "seek", "-1" ] }' | socat - /tmp/mpvsocket
  27.  
  28. ###the above commands don't show the OSD (On Screen Display)
  29. #if you want, you can send keypresses instead, which will show OSD
  30. echo '{ "command": [ "keypress", "right" ] }' | socat - /tmp/mpv.socket
  31. echo '{ "command": [ "keypress", "left" ] }' | socat - /tmp/mpvsocket
  32. echo '{ "command": [ "keypress", "up" ] }' | socat - /tmp/mpvsocket
  33. echo '{ "command": [ "keypress", "down" ] }' | socat - /tmp/mpvsocket
  34. ##get a full list of keys with this command
  35. mpv --input-keylist
  36.  
  37. #you can list all options like this
  38. mpv --list-properties
  39.  
  40. #or, if you know the shortcut keys, you can always use them
  41. echo '{ "command": [ "keypress", "]" ] }' | socat - /tmp/mpvsocket #speed up
  42. echo '{ "command": [ "keypress", "[" ] }' | socat - /tmp/mpvsocket #slow down
  43. #reset speed by sending BACKSPACE key list this
  44. echo '{ "command": [ "keypress", "BS" ] }' | socat - /tmp/mpvsocket
  45.  
  46. #screenshot
  47. echo '{ "command": [ "keypress", "s" ] }' | socat - /tmp/mpvsocket
  48.  
  49. ###other commands
  50. #send your own message to screen
  51. echo '{"command":["show-text","This is a message"]}' | socat - /tmp/mpvsocket
  52.  
  53. #show OSD of current position
  54. echo show-progress | socat - /tmp/mpvsocket
  55.  
  56. #i3 keybindings
  57. bindsym XF86AudioPlay  exec echo cycle pause   | socat - /tmp/mpvsocket
  58. bindsym XF86AudioPause exec echo cycle pause   | socat - /tmp/mpvsocket
  59. bindsym XF86AudioStop  exec echo cycle pause   | socat - /tmp/mpvsocket
  60. bindsym XF86AudioPrev  exec echo playlist_prev | socat - /tmp/mpvsocket
  61. bindsym XF86AudioNext  exec echo playlist_next | socat - /tmp/mpvsocket
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement