hankhank10/vinylemulator

Issue with Sonos queue and Apple Music

derfeger9000 opened this issue · 3 comments

Hi Mark,

This is a great build and a perfect writeup, I was done in almost 60 minutes...
Now I am having an issue (or several) with the way the script calls the Sonos queue when using Apple Music.
If the queue is empty, everything runs as intended. Fill queue and start with track 1.
If the same album already runs, it will restart with track 2. It should restart with track 1.
If a playlist already runs in random, the script will correctly empty the queue and fill it with the album on the chip, but will keep the random setting and start with any track.
Is there any chance you can change this behaviour?

Thanks
Marius

regarding the Apple Music queue starting at track 2:

I ran into the same issue. clearing the queue before playing an album would start the album at track 1 100% of the time. Starting a new album without clearing the queue almost never started the album at track 1.

I was able to reduce this behavior pretty significantly by adding the following to line 71 to readnfc.py

time.sleep(1)

I tried shorter intervals (.250 and .500) but that didn't seem to be enough time. I haven't tested with longer intervals. My novice observation is that Sonos seems to need a literal second to process the clear queue command when handling Apple Music content. I haven't seen anyone mention this same behavior with Spotify.

my daughter has been using this whole setup pretty non-stop for the past 10 or so days. After forcing the script to wait a second after the clear_queue command we've only had the albums start at track 2 a couple of times, and it's usually when she's quickly switching albums.

That's the fix for the track 1 issue, so far all my tests started at track 1. But i inserted it in Line 91, not 71.
Thanks a lot

I will open a new thread for the shuffle issue.