Shuffle play a playlist with mpv includes a webui
Go to file
2024-11-05 01:20:33 +00:00
example_config.sh changed example webpage location 2024-11-03 20:50:19 +00:00
LICENSE Initial commit 2024-11-03 20:51:14 +01:00
mpvmusic.sh mpv reloads properly if it crashes 2024-11-05 01:20:33 +00:00
README.md added timeout to reload when going to next song 2024-11-04 22:24:21 +00:00

mpvmusic webui

A basic webui for mpv --shuffle

Dependencies

exiftool
jq
mpv

# 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

Intergrating with a node web server

You'll need these functions in your node server:

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);
});
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);
});

Change the "/music/{event}" to wherever your webui posts to.