Skip to content

Conversation

patso23
Copy link
Contributor

@patso23 patso23 commented May 16, 2025

Jukebox mode doesn't include MusicFolder in mpv command in mpv command - #4066

The call to createMPVCommand is not including the MusicFolder path in mpv command causing it to fail with file not found errors.

Updated createMPVCommand to use filepath.Join with conf.server.MusicFolder

…er in mpv command - navidrome#4066

The call to createMPVCommand is not including the MusicFolder path in
mpv command causing it to fail with file not found errors.

Updated default command template and createMPVCommand to use additional
substitution with conf.server.MusicFolder

Signed-off-by: Pat <patso.oshea@gmail.com>
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

Looks good to me! 👍

Reviewed everything up to 0609de3 in 47 seconds. Click for details.
  • Reviewed 25 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. conf/configuration.go:458
  • Draft comment:
    The default mpv command template now uses a '%p/%f' pattern. Note that hardcoding '/' may cause issues on Windows or if MusicFolder already ends with a slash. Consider using a platform‐independent join (e.g. filepath.Join) or ensure proper formatting.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None
2. core/playback/mpv/mpv.go:77
  • Draft comment:
    Addition of '%p' replacement in createMPVCommand correctly inserts MusicFolder. Be aware that simple string replacement may break if the folder or filename contains spaces. Consider using a more robust method (e.g. filepath.Join) for path construction.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None

Workflow ID: wflow_5jEcOfYghDHkuV9D

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@patso23
Copy link
Contributor Author

patso23 commented May 16, 2025

Apologies, first time attempting to contribute and I hadn't considered cross platform paths. Will try to push an update soon

@patso23
Copy link
Contributor Author

patso23 commented May 16, 2025

Apologies, first time attempting to contribute and I hadn't considered cross platform paths. Will try to push an update soon

Updated

@patso23 patso23 changed the title fix(configuration.go, mpv.go): Jukebox mode doesn't include MusicFold… fix(mpv.go): Jukebox mode doesn't include MusicFold… May 16, 2025
Copy link
Member

@deluan deluan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution, check my comments.

By the way, I'm curious why the few folks out there that use the current Jukebox implementation didn't complain before.

@tcurdt sorry for the ping, but as you are the most vocal Jukebox user I know, do you get this error as well?

@@ -74,7 +75,7 @@ func createMPVCommand(deviceName string, filename string, socketName string) []s
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, "%f", filepath.Join(conf.Server.MusicFolder, filename))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The correct way to do this is to call createMPVCommand with mf.AbsolutePath():

args := createMPVCommand(deviceName, mf.Path, tmpSocketName)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, first time looking at the the code of course. This makes more sense for the caller to be corrected. Will push an update

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deluan, just pushed the update to use AbsolutePath() in the caller.

I did see in another issue that people noticed this problem and had solved it by prepending their MusicFolder path in the mpv command template itself as a workaround.

But I think @tcurdt is right about the problem using spaces to tokenize the command. That go shellwords could be the way to go, I might play around with that. But figured getting this change in for people might be good in the interim

@@ -477,7 +477,7 @@ func setViperDefaults() {
viper.SetDefault("ignoredarticles", "The El La Los Las Le Les Os As O A")
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("ffmpegpath", "")
viper.SetDefault("mpvcmdtemplate", "mpv --audio-device=%d --no-audio-display --pause %f --input-ipc-server=%s")
viper.SetDefault("mpvcmdtemplate", "mpv --audio-device=%d --no-audio-display %f --input-ipc-server=%s")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What this -pause is used for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why the pause was there in the first place.

It was causing every song I started in jukebox mode to go straight into a paused state which didn't make sense. That's why I removed it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What client are you using @patso23 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tcurdt DSub currently

@tcurdt
Copy link
Contributor

tcurdt commented May 28, 2025

sorry for the ping, but as you are the most vocal Jukebox user I know, do you get this error as well?

No worries. I am fine to be pinged :)

I had it working without this change (see the other discussion/ticket) but since I didn't get any traction I abandoned that route. Traction as in to properly rewrite it in Navidrome and to fix client support.

This change might go in the right direction but it feels like putting lipstick on a (dead) pig.
The quoting is still broken.

I am now using music assistant on top of navidrome which does the snapcast integration.
It's not the solution I wanted. It's not exactly great. But it is something that is working now.
With everything else, I felt like Don Quixote.

I am still happy to help on fixing this, but this needs more work. Both on the server and the client side.
...which may or may not be a chicken and egg problem.

@daredoes
Copy link

@deluan I can confirm that these fixes work when applied directly via config. I put Navidrome jukebox away for awhile and relied on Mopidy3 if I really wanted local playback. With these changes though, it's at least good enough to kick off an album or playlist and move on.

Jukebox.Devices = [
    [ "snapcast",     "snapcast" ],
]
Jukebox.Default = "snapcast"
Jukebox.Enabled = true
MPVPath = ""
MPVCmdTemplate = "mpv --no-audio-display /music/%f --input-ipc-server=%s --audio-channels=stereo --audio-samplerate=48000 --audio-format=s16 --ao=pcm --ao-pcm-file=/tmp/host/navidrome"

Above is my config, which has the following major changes

  1. Removing --pause seems to solve the original error in this issue of msg="Got mpv error, retrying..." error="mpv error: property unavailable" retries=1
  2. Set /music/ for my absolute local music path before %f and specifically DID NOT wrap this in quotes.

To test my server, I'm using Jamstash on my computer and iSub/AVSub on my iPhone.

For all of these apps the jukebox mode controls are not working as expected. Biggest flaws are not being able to track the playback state properly, or get a queue of what's playing. The error from the linked issue mpv error: property unavailable has me thinking that this comes from the lack of proper UI controls for Jukebox in Navidrome.

How hard could it be for me to add them myself, right? 😇

@deluan deluan merged commit a79e05b into navidrome:master Jun 3, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Jukebox mode doesn't include MusicFolder in mpv command [Bug]: mpv errors when trying to use jukebox mode
4 participants