Skip to content

🎧 Your Personal Streaming Service

Externalize MPV command template (#2948)

Jonathanbcec15dc13d6
diff --git a/conf/configuration.go b/conf/configuration.go
index 118557e17..cfb644143 100644
--- a/conf/configuration.go
+++ b/conf/configuration.go
@@ -57,6 +57,7 @@ type configOptions struct {
SubsonicArtistParticipations bool
FFmpegPath string
MPVPath string
+ MPVCmdTemplate string
CoverArtPriority string
CoverJpegQuality int
ArtistArtPriority string
@@ -303,6 +304,8 @@ func init() {
viper.SetDefault("indexgroups", "A B C D E F G H I J K L M N O P Q R S T U V W X-Z(XYZ) [Unknown]([)")
viper.SetDefault("subsonicartistparticipations", false)
viper.SetDefault("ffmpegpath", "")
+ viper.SetDefault("mpvcmdtemplate", "mpv --audio-device=%d --no-audio-display --pause %f --input-ipc-server=%s")
+
viper.SetDefault("coverartpriority", "cover.*, folder.*, front.*, embedded, external")
viper.SetDefault("coverjpegquality", 75)
viper.SetDefault("artistartpriority", "artist.*, album/artist.*, external")
diff --git a/core/playback/mpv/mpv.go b/core/playback/mpv/mpv.go
index 8b10c5b91..7fb5d2a32 100644
--- a/core/playback/mpv/mpv.go
+++ b/core/playback/mpv/mpv.go
@@ -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
}
diff --git a/core/playback/mpv/track.go b/core/playback/mpv/track.go
index 12876a206..3d4dfcd74 100644
--- a/core/playback/mpv/track.go
+++ b/core/playback/mpv/track.go
@@ -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)