Advertisement
metalx1000

MPV Controls in Shell with Socat

Jul 20th, 2023
1,803
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.94 KB | None | 0 0
  1. #play all mp3s in current directory (without video display)
  2. mpv --no-vid --input-ipc-server=/tmp/mpvsocket *.mp3
  3.  
  4. #now mpv commands can be sent to /tmp/mpvsocket with socat
  5. echo cycle pause | socat - /tmp/mpvsocket
  6. echo playlist_prev | socat - /tmp/mpvsocket                                                                                                  
  7. echo playlist_next | socat - /tmp/mpvsocket
  8.  
  9. #Jump forward of back 5 seconds
  10. echo seek  5| socat - /tmp/mpvsocket
  11. echo seek  -5| socat - /tmp/mpvsocket
  12.  
  13. #You can also send key presses
  14. #Example for Volume Control
  15. echo '{ "command": [ "keypress", "0" ] }' | socat - /tmp/mpvsocket
  16. echo '{ "command": [ "keypress", "9" ] }' | socat - /tmp/mpvsocket
  17.  
  18. #if you have youtube-dl install you can stream playlists
  19. mpv --no-vid --input-ipc-server=/tmp/mpvsocket "https://www.youtube.com/playlist?list=PLG1znKjmrCrZfQAWkBjQsFw-gLuHzTNa4"
  20.  
  21. #note, kill previous mpv before starting a new process.  
  22.  
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement