jishi / node-sonos-http-api

An HTTP API bridge for Sonos easing automation. Hostable on any node.js capable device, like a raspberry pi or similar.
http://jishi.github.io/node-sonos-http-api/
MIT License
1.84k stars 463 forks source link

musicsearch no longer plays the file you search for? #711

Open hotleafjuice opened 5 years ago

hotleafjuice commented 5 years ago

When invoking musicsearch (in this case, targeting files in the local music library), the single file located always used to be added to the queue as the next song, and immediately would begin playing.

This was working as of June 1, 2019.

Now (August 7, 2019), when the same call to musicsearch is made, the single file located is, as before, added to the queue as the next song, but now the queue always plays the second song in the queue overall, instead of playing the new song. This pretty much breaks the functionality for what I use it for.

I am suspecting that Sonos pushed some kind of mandatory update that broke this, but I have no proof. What I am surmising is happening is that the song is added as the next song, but then the current song pointer is returned to the top before going to play the next song, so the song that plays is always the second song in the queue, rather than the newly added song, which is the desired (and previous) behavior.

FYI, here is the call I am making to musicsearch:

http://localhost:5005/RoomName/musicsearch/library/song/song+name

This used to work, but now does not. I installed the newest version of the API and updated dependencies, but that did not resolve the issue.

hotleafjuice commented 5 years ago

OK, maybe I resolved this myself. Not sure. So, I edited musicSearch.js in the actions folder and in the else branch with the comment "// Play the one specified song" (line 255 in my environment), I commented out the following line:

.then(() => player.coordinator.setAVTransport(queueURI, ''))

Upon saving it and restarting the service, the previous behavior has been restored -- upon calling musicsearch and returning a single song, the song is added and the track advanced to the new song as before.

Upon reverting the code (un-commenting the above line) and restarting the service, it once again was adding the new song in the right place but always playing the second song in the queue.

So, it appears that commenting out the above line restores the previous behavior. Not sure what may have caused this (or even what that line does), but if it works, it works (or well, that's enough for me for now).

By the way, jishi, this API is just the best and you are a hero for making it.

jishi commented 5 years ago

That line switches the player to "queue" playback, and should only be done if the player is in some other mode (radio, certain streaming services). I'm not surprised that the queue pointer get reset if that is invoked, os question is then if the identification if player is already in queue mode is broken. I'm gonna need to have a look. Which Sonos software version are you running on your players?

hotleafjuice commented 5 years ago

I'm running Version: 10.3 (build 51166240)

Can't believe how quickly you responded... wow, thanks! Awesome.