Externalize MPV command template (#2948)

* externalise MPVTemplate

* Remove unnecessary comment

---------

Co-authored-by: Deluan <deluan@navidrome.org>
This commit is contained in:
Jonathan
2024-04-16 03:31:54 +02:00
committed by GitHub
parent cf6603e3ec
commit bcec15dc13
3 changed files with 6 additions and 9 deletions
+2 -8
View File
@@ -14,11 +14,6 @@ import (
"github.com/navidrome/navidrome/log"
)
// mpv --no-audio-display --pause 'Jack Johnson/On And On/01 Times Like These.m4a' --input-ipc-server=/tmp/gonzo.socket
const (
mpvComdTemplate = "mpv --audio-device=%d --no-audio-display --pause %f --input-ipc-server=%s"
)
func start(args []string) (Executor, error) {
log.Debug("Executing mpv command", "cmd", args)
j := Executor{args: args}
@@ -78,15 +73,14 @@ func (j *Executor) wait() {
}
// Path will always be an absolute path
func createMPVCommand(cmd, deviceName string, filename string, socketName string) []string {
split := strings.Split(fixCmd(cmd), " ")
func createMPVCommand(deviceName string, filename string, socketName string) []string {
split := strings.Split(fixCmd(conf.Server.MPVCmdTemplate), " ")
for i, s := range split {
s = strings.ReplaceAll(s, "%d", deviceName)
s = strings.ReplaceAll(s, "%f", filename)
s = strings.ReplaceAll(s, "%s", socketName)
split[i] = s
}
return split
}
+1 -1
View File
@@ -33,7 +33,7 @@ func NewTrack(playbackDoneChannel chan bool, deviceName string, mf model.MediaFi
tmpSocketName := socketName("mpv-ctrl-", ".socket")
args := createMPVCommand(mpvComdTemplate, deviceName, mf.Path, tmpSocketName)
args := createMPVCommand(deviceName, mf.Path, tmpSocketName)
exe, err := start(args)
if err != nil {
log.Error("Error starting mpv process", err)