(01-24-2024, 10:09 PM)cogitech Wrote: Interestingly, spotevent.sh does not reference that variable at all. Perhaps Tim had some plans for this in the future?This script, for what I see, is used to a) stop mpd when Spotify takes over, and b) eventually resume mpd playback when Spotify ends, and the behavior is set so in the configuration. Good it is there, so we can use it.
Quote:I agree, it really looks like your script code could be integrated into spotevent.sh. Something like:
if [[ $PLAYER_EVENT == "playing" ]]; then run Al's code with "$TRACK_ID" and dump the metadata [/to/some/file]
Then the overlay php can grab what it needs from [/to/some/file].
We need also to check if the track ID is different from the last one.
It could either write a file and some service at intervals could check it; or it may invoke the php, a more reactive solution IMO, if it is viable, of course.
My script also needs to be tested during playback, to see what is the impact against the caller - that is: librespot, aka the player... if the call is blocking and the operation takes long, it could affect playback...
ETA
There are variables being set, at least this is what the log has to say... there is PLAYER_EVENT, OLD_TRACK_ID and TRACK_ID...
so a if [ PLAYER_EVENT == changed && OLD_TRACK_ID != TRACK_ID ] should keep us on the safe side...
There is also the DURATION and POSITION_MS, both in ms
I am a bit rusty about shell variables... and can't use librespot, but I may think of giving you a small change to the spotevent.sh script just to check if we can detect the correct moment to interrogate spotify...