03-22-2021, 02:34 PM
Sorry if I'm hijacking this thread, but from its title, it looks like the right one to me.
I've further investigated this possible feature and I got some promising results. This is what I've done so far:
0. Open a SSH session to your moode raspberry pi IP.
1. Stop librespot (included with moOde and started if you activate a Spotify renderer). F.i.: using htop.
2. Install vollibrespot. This is a small wrapper around the librespot core library that broadcasts Spotify song metadata through udp:
wget https://github.com/ashthespy/Vollibrespo...v7l.tar.xz
tar -xf vollibrespot-armv7l.tar.xz
3. The parameters that moOde uses for librespot can be seen in /www/inc/playerlib.php (line 2633). Some of them are gathered from the moOde configuration parameters you complete from the web UI. The exact parameters used to launch last session could be seen in htop (before killing librespot), for instance.
4. Vollibrespot doesn't use the same command line args as librespot. You need to create and edit a toml file (config.toml). Most of the parameters are the same; only the onevent argument doesn't exist. More on that later.
5. You can start now vollibrespot, and you will see your "moOde Spotify connect renderer" from a Spotify app on another device, and you can play some music through moOde:
sudo ./vollibrespot -c ./config.toml --verbose
6. I've created a small simple php script (udpclient.php) that reads Spotify song metadata from UDP port 5030 and sends commands (play, stop,...) to UDP port 5031. When I launch it, I can see the song metadata in the terminal.
7. Since librespot no longer starts this shell script: /var/local/www/commandw/spotevent.sh (no onevent command line parameter, as seen in 4), moOde does not show the usual "dark gray cover modal" (in header.php: inpsrc-msg "INPUT SOURCE INDICATOR").
I would say that the proof of concept was successful.
Of course, many other things would be needed to fully support this feature. At least:
1. Wanting to swap the librespot daemon for vollibrespot. (:-)) = introducing a new piece in the puzzle = risking reliability. I perfectly understand that.
2. Modifying the startSpotify function in /www/inc/playerlib.php to launch vollibrespot instead of librespot.
3. Creating a config.toml template for vollibrespot, and updating some parameters with $cfg_spotify variables (coming from moOde UI Spotify configuration).
4. Starting a thread that reads from UDP 5030 and writes to UDP 5031 (like my sample udpclient.php does), and stores the song metadata in some global variables/sqlite3/whatever.
5. Update spotevent.sh to the new way of getting metadata and Spotify events.
6. Modifying header.php / INPUT SOURCE INDICATOR to autorefresh (every couple of seconds) and show song/artist/... from the aforementioned global variables/sqlite3/...
7. Modifying the install procedure to additionally download and untar vollibrespot.
8. Testing, testing and testing to see if there are reliability issues.
I'd be happy to help here, but as a moOde newcomer (and not a pro php prog.) there are many things I don't now how to do.
I've further investigated this possible feature and I got some promising results. This is what I've done so far:
0. Open a SSH session to your moode raspberry pi IP.
1. Stop librespot (included with moOde and started if you activate a Spotify renderer). F.i.: using htop.
2. Install vollibrespot. This is a small wrapper around the librespot core library that broadcasts Spotify song metadata through udp:
wget https://github.com/ashthespy/Vollibrespo...v7l.tar.xz
tar -xf vollibrespot-armv7l.tar.xz
3. The parameters that moOde uses for librespot can be seen in /www/inc/playerlib.php (line 2633). Some of them are gathered from the moOde configuration parameters you complete from the web UI. The exact parameters used to launch last session could be seen in htop (before killing librespot), for instance.
4. Vollibrespot doesn't use the same command line args as librespot. You need to create and edit a toml file (config.toml). Most of the parameters are the same; only the onevent argument doesn't exist. More on that later.
5. You can start now vollibrespot, and you will see your "moOde Spotify connect renderer" from a Spotify app on another device, and you can play some music through moOde:
sudo ./vollibrespot -c ./config.toml --verbose
6. I've created a small simple php script (udpclient.php) that reads Spotify song metadata from UDP port 5030 and sends commands (play, stop,...) to UDP port 5031. When I launch it, I can see the song metadata in the terminal.
7. Since librespot no longer starts this shell script: /var/local/www/commandw/spotevent.sh (no onevent command line parameter, as seen in 4), moOde does not show the usual "dark gray cover modal" (in header.php: inpsrc-msg "INPUT SOURCE INDICATOR").
I would say that the proof of concept was successful.
Of course, many other things would be needed to fully support this feature. At least:
1. Wanting to swap the librespot daemon for vollibrespot. (:-)) = introducing a new piece in the puzzle = risking reliability. I perfectly understand that.
2. Modifying the startSpotify function in /www/inc/playerlib.php to launch vollibrespot instead of librespot.
3. Creating a config.toml template for vollibrespot, and updating some parameters with $cfg_spotify variables (coming from moOde UI Spotify configuration).
4. Starting a thread that reads from UDP 5030 and writes to UDP 5031 (like my sample udpclient.php does), and stores the song metadata in some global variables/sqlite3/whatever.
5. Update spotevent.sh to the new way of getting metadata and Spotify events.
6. Modifying header.php / INPUT SOURCE INDICATOR to autorefresh (every couple of seconds) and show song/artist/... from the aforementioned global variables/sqlite3/...
7. Modifying the install procedure to additionally download and untar vollibrespot.
8. Testing, testing and testing to see if there are reliability issues.
I'd be happy to help here, but as a moOde newcomer (and not a pro php prog.) there are many things I don't now how to do.