SqueezeBox playSound doesn't resume the right track?

Tags: #<Tag:0x00007f744adbdf60>

I’m using playSound as part of the Squeezebox binding to play mp3 based notifications like… “The garage door is still open”.

I’m noticing that after the mp3 is played if a song was playing it resumes at the right time in the track but a COMPLETELY random track in the currently playlist on the squeezebox.

Anyone know if this is a known issue or have a fix for it?

UPDATE… This appears to happen when my playlist is on “random” shuffle. But looks to work okay wen not random.

In your rule, save the current track before playing the mp3 in a variable, then after the mp3 is played resume play using the saved track

Thanks Vincent although that seems like a bit of a workaround for a bug?

A couple of lines codes is not a great workaround.
In the mean time, you can report the bug as an issue on github.

Is this happening when you are playing a playlist containing local music files (versus a streaming source like Pandora, Spotify, etc.)?

There may be an issue with the order in which the player state is being restored after the notification completes. I’ll take a look at this. Unfortunately, I’ve found the LMS to be a bit (for lack of a better word) squirrelly when restoring the player state after the notification completes. :roll_eyes:

Yeah when playing local music and the playbac is set to random shuffle.

I was going to try sending a command to pause first, play the notification and then another command to un-pause… Maybe that will be more reliable?

That’s basically what the binding does when it detects something is currently playing.

  • save player state, including currently playing item, shuffle mode, repeat mode, mute, etc.
  • turn off shuffle (if on)
  • turn off repeat (if on)
  • stop player
  • add notification to end of playlist
  • play last item in playlist (i.e. notification)
  • remove last item in playlist (i.e. notification)
  • restore currently playing item
  • restore playing time
  • restore shuffle mode
  • restore repeat mode

Note that the currently playing item is the index of the song in the playlist, not the song itself.

I’m thinking that turning off shuffle mode might change the association between the index and the actual song. But I need to test this.

Yeah I suspect doing the “restore shuffle” will make it end up with a playlist in a different order so the song index will be wrong.

Is there a difference if i play a song out of a playlist or i play a song out of a folder without any playlist?

Is there the same behavior with all commands (shuffle, repeat) or is there a difference if i play playlist or folder?

I haven’t looked closely at the LMS code, but I expect the behavior will be the same.

So, the way the LMS seems to work… Say you have shuffle by song enabled (haven’t tested shuffle by album yet) and you’re on track index 20 of a playlist (i.e. that’s the playlist index of the currently playing song). Disabling and reenabling shuffle mode seems to place the currently playing song at playlist index 0.

I’m going to test a change that restores the index to 0 when shuffle mode is enabled.

Edit: Well, that didn’t work. :frowning_face: Adding an item (i.e. the notification) to the playlist and playing it invalidates the above behavior.

When playing a playlist of local music, another possibility is to try using the playlist save, playlist clear, and playlist resume commands. I’ve never used those before, and it likely would involve a bit more rework. I’ll take a look at that when I get a little more time.

Just out of interest, why do you disable the shuffle and repeat first? Is that so the notification can be played “next”?

Right. The notification goes at the end of the playlist, then the last item in the playlist is played. When the notification is complete the player stops, after which the state is restored. If the notification is not at the end, the next song after the notification will start playing immediately, which is not desirable, nor is it easy to detect.

Of course, there may be a completely different way to do this using the LMS CLI, but I haven’t found it yet…

@mhilbush, just upgraded to 2.3.0 today and if my squeezebox is playing a list of random songs then when it resumes after a speak notification it is still not resuming the same track…
Did you think you had resolved this?

I’m pretty confident that I haven’t resolved it. I haven’t been able to find anything in the LMS API that will make this work better.

Thanks for trying! I’ll have to remember not to use shuffle where possible :wink:

Hi This is somehow offtopic, but I don’t want to rise another one unnecessarily.
@mhilbush is this possible from binding to clear the current playlist of particular squeezebox player?

The API has a playlist clear function. The binding might be able to implement this as a Thing action that could be called from a rule.

<playerid> playlist clear

The "playlist clear" command removes any song that is on the playlist. The player is stopped.

Examples:

Request: "04:20:00:12:23:45 playlist clear<LF>"
Response: "04:20:00:12:23:45 playlist clear<LF>"