mpvmusic/README.md

51 lines
1.2 KiB
Markdown
Raw Permalink Normal View History

2024-11-03 21:27:14 +01:00
# mpvmusic webui
2024-11-03 20:51:14 +01:00
2024-11-03 21:27:14 +01:00
A basic webui for mpv --shuffle
2024-11-03 21:19:47 +01:00
## Dependencies
2024-11-03 21:22:07 +01:00
exiftool<br/>
jq<br/>
mpv<br/>
```shell
# Debian based
$ sudo apt install exiftool jq mpv
# Arch
$ sudo pacman -Syu exiftool jq mpv
# Should work on other systems too, these are pretty universal programs
```
2024-11-03 21:19:47 +01:00
## Intergrating with a node web server
You'll need these functions in your node server:
```javascript
const express = require('express');
const { exec } = require("child_process");
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
app.post("/music/playpause",(req,res) => {
console.log("toggling pause!")
exec('echo cycle pause | socat - "/tmp/mpvsocket"');
res.redirect(302, req.get("referer"));
});
app.post("/music/next",(req,res) => {
console.log("skipping to next song")
exec('echo playlist-next | socat - "/tmp/mpvsocket"')
setTimeout(function() {
res.redirect(302, req.get("referer"));
}, 750);
2024-11-03 21:19:47 +01:00
});
app.post("/music/prev",(req,res) => {
console.log("going back to previous song")
exec('echo playlist-prev | socat - "/tmp/mpvsocket"')
setTimeout(function() {
res.redirect(302, req.get("referer"));
}, 750);
2024-11-03 21:19:47 +01:00
});
```
Change the "/music/{event}" to wherever your webui posts to.