Posts: 1,404
Threads: 24
Joined: Jun 2022
Reputation:
50
Hi all,
this thread was made specifically to keep all information and discussions about the topic - achieve metadata / album-art display with spotify-connect through librespot event signaling and http parsing.
There are already libraries (mainly for various dialects of JS, such as Angular) but we chose a different approach. Well, we chose what those libraries do at their innards (retrieve a web page and parse it, from within a browser engine), but without all the browser around.
curl for the page retrieval and sed for the stream filtering have been the tools.
Posts: 42
Threads: 3
Joined: Dec 2023
Reputation:
1
01-26-2024, 02:43 PM
(This post was last modified: 01-26-2024, 02:48 PM by cogitech.)
Pulling this over from the other thread. Al, I will still do as you requested below, when I have some time. Maybe today, maybe next week. I want to set up a moOde server on a separate Rpi for testing this stuff. Earlier I was using my main "production" moode server for testing and messed it up a bit when I fat-fingered the php code. I was able to fix it, but I'd rather make those mistakes on a system that nobody in the home relies on.
_______________________________
Hi,
can you modify the /var/local/www/commandw/spotevent.sh and add the following lines, always, that is, before the very first IF
(then we need to change that script, because ATM for any event other than "started" or "stopped" it just exits... adding these lines before the test at least gets us how-and-when it gets called...)
echo "`date +%Y-%m-%dT%T.%N` - PLAYER_EVENT = ${PLAYER_EVENT}" >> /var/log/moode_spotevent.log
echo "`date +%Y-%m-%dT%T.%N` - OLD_TRACK_ID = ${OLD_TRACK_ID}" >> /var/log/moode_spotevent.log
echo "`date +%Y-%m-%dT%T.%N` - TRACK_ID = ${TRACK_ID}" >> /var/log/moode_spotevent.log
echo "`date +%Y-%m-%dT%T.%N` - DURATION_MS = ${DURATION_MS}" >> /var/log/moode_spotevent.log
echo "`date +%Y-%m-%dT%T.%N` - POSITION_MS = ${POSITION_MS}" >> /var/log/moode_spotevent.log
Then, cast some songs in Spotify, and also do the following:
1. play a song, wait for it to finish, and play the next song. After some time you can stop it.
2. play a song, halfway through select another one to play
3. play a playlist, at least two songs (or do as at point 1)
This to see how many times the script gets called; hopefully only one time per event (STOP / PLAYING / CHANGED)
Cheers, Al.
Posts: 1,404
Threads: 24
Joined: Jun 2022
Reputation:
50
(01-26-2024, 02:43 PM)cogitech Wrote: Pulling this over from the other thread. Al, I will still do as you requested below, when I have some time. Maybe today, maybe next week. I want to set up a moOde server on a separate Rpi for testing this stuff. Earlier I was using my main "production" moode server for testing and messed it up a bit when I fat-fingered the php code. I was able to fix it, but I'd rather make those mistakes on a system that nobody in the home relies on.
_______________________________
Hi,
can you modify the /var/local/www/commandw/spotevent.sh and add the following lines, always, that is, before the very first IF
(then we need to change that script, because ATM for any event other than "started" or "stopped" it just exits... adding these lines before the test at least gets us how-and-when it gets called...)
echo "`date +%Y-%m-%dT%T.%N` - PLAYER_EVENT = ${PLAYER_EVENT}" >> /var/log/moode_spotevent.log
echo "`date +%Y-%m-%dT%T.%N` - OLD_TRACK_ID = ${OLD_TRACK_ID}" >> /var/log/moode_spotevent.log
echo "`date +%Y-%m-%dT%T.%N` - TRACK_ID = ${TRACK_ID}" >> /var/log/moode_spotevent.log
echo "`date +%Y-%m-%dT%T.%N` - DURATION_MS = ${DURATION_MS}" >> /var/log/moode_spotevent.log
echo "`date +%Y-%m-%dT%T.%N` - POSITION_MS = ${POSITION_MS}" >> /var/log/moode_spotevent.log
Then, cast some songs in Spotify, and also do the following:
1. play a song, wait for it to finish, and play the next song. After some time you can stop it.
2. play a song, halfway through select another one to play
3. play a playlist, at least two songs (or do as at point 1)
This to see how many times the script gets called; hopefully only one time per event (STOP / PLAYING / CHANGED)
Cheers, Al.
No worries, set up your working environment from a fresh install.
Then you can just swap an SDcard where you will tackle with out madness...
I was thinking, that to communicate back to the UI we'll probably need a socket, and for that matter also something like mpd running in the background... and something to control it. For ordinary playback at the moment we have MPD and MPC, we shall have something like SMC (S.potify M.etadata C.ontroller), which has an open socket connection towards the Spotify UI: upon metadata change we'll invoke SMC with the relevant data, and it will pipe the data to the UI.
I still have to investigate the whole thing, but I think I can come up with something early next week (if not tonight, I mean...)
But the test I asked you to perform is crucial to be able to determine the load of the script invoked by librespot.
Posts: 14,016
Threads: 319
Joined: Mar 2018
Reputation:
571
There are already a couple ways to get beck-end data to the front-end without having to invent new plumbing. There is also a need to be able to reload the data any time the page is refreshed.
When I get some time I'll point you to the code
Posts: 1,404
Threads: 24
Joined: Jun 2022
Reputation:
50
(01-26-2024, 05:53 PM)Tim Curtis Wrote: There are already a couple ways to get beck-end data to the front-end without having to invent new plumbing. There is also a need to be able to reload the data any time the page is refreshed.
When I get some time I'll point you to the code
Cool 
thanks.
Posts: 2
Threads: 0
Joined: Jan 2024
Reputation:
0
I just posted on the other thread also so i figured i'd post here also.
https://moodeaudio.org/forum/showthread.php?tid=6164
I was wondering if we should rewire Moode to use librespot-java which has a local API that can control playback as well as read metadata. I think it has websockets for events also.
Posts: 1,404
Threads: 24
Joined: Jun 2022
Reputation:
50
(01-31-2024, 07:27 PM)robinhood Wrote: I just posted on the other thread also so i figured i'd post here also.
https://moodeaudio.org/forum/showthread.php?tid=6164
I was wondering if we should rewire Moode to use librespot-java which has a local API that can control playback as well as read metadata. I think it has websockets for events also.
As you have seen, I replied on the other thread...
The main problem IMO is Java. And - as far as I understand - that it should be not headless in order to use the audio sink.
Posts: 14,016
Threads: 319
Joined: Mar 2018
Reputation:
571
Please do not cross-post. It makes things very messy.
Posts: 14,016
Threads: 319
Joined: Mar 2018
Reputation:
571
(01-31-2024, 08:13 PM)Nutul Wrote: (01-31-2024, 07:27 PM)robinhood Wrote: I just posted on the other thread also so i figured i'd post here also.
https://moodeaudio.org/forum/showthread.php?tid=6164
I was wondering if we should rewire Moode to use librespot-java which has a local API that can control playback as well as read metadata. I think it has websockets for events also.
As you have seen, I replied on the other thread...
The main problem IMO is Java. And - as far as I understand - that it should be not headless in order to use the audio sink.
Right, Java is a no-go.
Posts: 1,404
Threads: 24
Joined: Jun 2022
Reputation:
50
(01-31-2024, 08:23 PM)Tim Curtis Wrote: Right, Java is a no-go.
I wasn't in a position to put it as plain as this, but somehow had the feeling.
|