hklages / node-red-contrib-sonos-plus

A set of Node-RED nodes to control SONOS player in your local network.
MIT License
75 stars 14 forks source link

Not an issue - help needed with project kids player with different Spotify playlists #248

Closed mac89muc closed 2 months ago

mac89muc commented 1 year ago

Hello, once again I have a little challenge. My son is listening to his stories tkkg junior / die ??? kids / was ist was and a bit more on his Sonos player in his room and he can switch between them / control the player with a zigbee remote which is paired to the zigbee adapter to iobroker.

blocky scripts and your node-red Sonos contrib project manage that he can control his Sonos player without the need to use the regular buttons on the player itself. so I can define working hours of the remote and different max volumes for the day and evening.

I created a Spotify playlist with different albums/stories for each artist - tkkg junior - one for Die ??? Kids - one for Was ist Was and so on with ...

so until here everything is working fine, except the fact that every time he switches between the playlist of the different actors/artists always the fist album/story of the playlist is playing - which is logical.

so I need a possibility to randomize/shuffle the playlist sequence when he's switching between the playlists so not every time he picks the e.g. tkkg playlist the same album/story is playing.

if I switch to random mode before playing - there's indeed a different song/part of the story but the following parts of the story are messed up - so not the whole same album/story is playing in the queue but different separate tracks from different stories are messed up in the queue.

For explanation - a story has different number of parts which are separate tracks on the story/album

example tkkg junior the album/story "Folge 14 - Eisige Diamanten" has 37 seperate titles. image

So if I deal with music and don't want to have only songs from one album shuffled - there would be no problem.

I played around and tried to use a little detour to shuffle the playlist stop playing and extract the album number (example Eisige Diamanten which has album number 14) then erasing the actual messed up playing queue and looking for the album number on Spotify for the selected album with the group.queue.urispotify but I got stuck and until now I haven't found any way to implement this process.

Maybe you or someone else has a suggestion and/or can guide me to a less complicated way - any help is appreciated

Regards & Grüße aus der Nachbarschaft

hklages commented 1 year ago

Hi again.

So you want to randomize the list of playlists.

Idea: Store all names of the playlists in an array (Node-RED flow or global variable) and randomly select an item = playlist and send that to the SONOS-Player for playing. Here is a node

mac89muc commented 1 year ago

Thanks for your fast reply - is there a way to automate the storing from the playlists to the array - not so familiar with this stuff...

hklages commented 1 year ago

Hallo. Da es sehr speziell ist, können wir auch in Deutsch weitermachen.

Ich verstehe den Sinn der Anwendung nicht. Üblicherweise startet man nur ein Hörbuch (Story) und hört sich das sequentiell an. Wieso willst du zwischen den Hörbüchern springen und dann auch noch die einzelnen Hörbücher in zufallsfolge abspielen?

Verstehe ich es richtig?

oder gibt es zu jedem Hörbuch eine Spotify Playlist und diese besteht aus den einzelnen Abschnitten

Mit welchem Befehl - topic und payload - "wechselst" du?

Nutze bitte den Befehl "group.get.queue" und schau dir die SONOS-Queue an. Stehe alle Hörbücher drin?

mac89muc commented 1 year ago

In der Tat sehr komplex und wahrscheinlich geht es viel einfacher - ich finde nur nicht den richtigen Ansatz.

Vielleicht ist das mit den verschiedenen Playlist auch zusätzlich verwirrend - an sich wäre das für meine Herausforderung aber erstmal irrelevant, ob eine, oder mehrer Playlisten.

Mir wäre schon geholfen, wenn ich z.B. diese Playlist Die drei ??? Kids - Alle Hörspiele wenn sie zum abspielen ausgewählt wird, nicht jedes mal mit der gleichen Folge startet, sondern auch eines der weiter hinten liegenden Folgen in der richtigen Titel-Reihenfolge abgespielt werden würde.

Ich möchte also aus der Playlist jedes mal beim starten der playlist zufällig eine Folge raussuchen die dann in korrekte Reihenfolge abgespielt wird.

Gruß

hklages commented 1 year ago

OK - Der Link ist hilfreich. Jetzt verstehe ich das Problem. Es ist eine lange (3476 Elemente) Playlist mit mehreren "Strories" und jede Story besteht meistens aus Intro, Ending und dazwischen die einzelnen "tracks" - alles einfach schlicht hintereinander ohne Unterplaylists oder Alben.

Wenn man von der Intro/Ending absieht ist die Namensgebung:

Wobei storynummer keine einheitliche syntax hat: mal 3 Ziffern "001 - ", mal 2 Ziffern "84 - " mal anderer Trenner "053/" aber zumindest trackname immer "Teil xx" ist, was ok ist. 1. Frage: Passt die Playlist in die SONOS Queue oder wird abgeschnitten? Das zu musst du die Playlist abspielen und während des Abspielens den Befehle `group.get.queue.length` senden. Der Wert sollte 3476 sein. 2. Wie "schaltest" du zwischen den Stories um? Woher weiß dein Sohn, dass "Gefahr im Dschungel" bei track 987 beginnt? Wahrscheinlich musst du dir die Arbeit machen einmal die Anfangsnummer für jede Story zu ermitteln und dann mit` group.play.track` dahin springen. Dann wird der erste Track gespielt und wenn keiner die Queue verändert wird mit stop/play auch richtig fortgesetzt.
mac89muc commented 1 year ago

Danke für Dein Feedback - ich hoffe ich komme die nächsten beiden Wochen mal wieder dazu mich mit dem Thema auseinanderzusetzen. Melde mich dann. Gruß

hklages commented 2 months ago

so far no response - closed.