From 6fef9c693b98bd8c2bf63162baedeb5123e963f3 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Sun, 28 May 2023 19:34:36 +0200 Subject: support custom mpv flags --- config.go | 1 + player.go | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/config.go b/config.go index 331fb7f..fd622dc 100644 --- a/config.go +++ b/config.go @@ -16,6 +16,7 @@ type Config struct { LocalMusicDir string `yaml:"music-dir"` UploadDir string `yaml:"upload-dir"` LogLevel string `yaml:"loglevel"` + MpvFlags string `yaml:"mpv_flags"` Admin uuid.UUID `yaml:"admin"` Spotify *SpotifyConfig `yaml:"spotify"` HasUpload bool diff --git a/player.go b/player.go index b2539dd..f1b01ac 100644 --- a/player.go +++ b/player.go @@ -3,6 +3,7 @@ package main import ( "io" "os/exec" + "strings" "sync" "syscall" @@ -76,9 +77,18 @@ func (player *Player) runMpv() { wrms.Next() } +const MPV_FLAGS = "--no-video" + func (player *Player) PlayUri(uri string) { llog.Info("Start mpv with %s", uri) - player.mpv = exec.Command("mpv", "--no-video", uri) + cmd := []string{"mpv", uri} + + cmd = append(cmd, strings.Split(MPV_FLAGS, " ")...) + + cmd = append(cmd, strings.Split(wrms.Config.MpvFlags, " ")...) + + llog.Debug("Running '%s'", strings.Join(cmd, " ")) + player.mpv = exec.Command("mpv", cmd...) go player.runMpv() } -- cgit v1.2.3