michaelherger / Spotty-Plugin

A Spotify plugin for the Lyrion Music Server (fka. Logitech Media Server) and Squeezebox compatible players
116 stars 20 forks source link

Call initHelpers when sync groups change (with Connect enabled) #87

Closed glogiotatidis closed 10 months ago

glogiotatidis commented 1 year ago

First of all thanks for the plugin and all the hard work! :cake:

I noticed that when i synchronize groups it takes a while for new player to appear in Spotify Connect. Changing DAEMON_WATCHDOG_INTERVAL from 60 to something low (e.g. 1) fixes the issue but that's a lot of polling.

The ideal would be to have a callback when clients change, similar to the ones you have when preferences change.

Fixing this will improve UX and increase the trust in the system, b/c the 60 second timeout makes the user wonder whether the plugin i working.

michaelherger commented 1 year ago

Hmm... I thought that's exactly what the following lines are trying to do:

https://github.com/michaelherger/Spotty-Plugin/blob/702d40d1f6f255c8e25970c59bf5b2daf801c556/Connect/DaemonManager.pm#L32-L42

glogiotatidis commented 1 year ago

You're right. Added some extra logs and I confirm that indeed when a new group is created a new helper gets launched.

Right after the new helper gets launched, a call to to checkAPIConnectPlayers fetches devices from Spotify and those devices are not returned. The daemon then kills he processes to "force restart".

I think it's a typical race condition. Can we delay checking Spotify's API for a second or something?

Also btw did you decide to change the name of the Spotify group when syncing devices? Can't we just keep the master player's name ? Is this a technical limitation or a preference?

michaelherger commented 10 months ago

Please see #34.