Headless Raspberry + Plexamp paired with Snapcast

Hello Community,
At home, I run Snapcast as my main audio distribution system. My Problem - i was not able to “pair” my plex sound output on a headless Raspberry (and have a cool remote feature). Now Plexamp solved my problem. Its a little complicated but the result is - from my point of view - awesome.

First of all, this is a hack based on plexamp-v1.0.5-pi.tar.gz and a running snapcast setup. Why, because it is using my favorite audio player mpd :slight_smile: . I don’t know if modern versions still use mpd.

Second - I use a raspberry pi 3 with the latest raspbian in my setup

My long Way … ( if you don’t like to read this scolle down to the HowTo)

At the beginning I followed the install instructions of elan in his post. Spoiler: It was not running as expected. Reason: the bundled mpd was not started correctly. After getting it running ( LD_LIBRARY_PATH=/home/pi/plexamp/resources/helpers/linux-arm ./mpd mpd.conf) I found out that the bundled mpd has no support for fifo output.
So I tried to use the regular mpd from the debian/raspbian-repos. I used the bundled mpd config - changed the audio output to a pipe - and started the the repo-mpd with the config - success - the node server was able to connect - time for music right now …
Not.
Next Problem - no music at all - f***. Thanks to the user StalkerSVR - he describes in his post how to get around the problem.
Again fire-ing up the node server and - drum roll - it works.
After some cleanup i can present the following HowTo

HowTo:

  1. Configure Plexamp and MPD
  • Login to your Raspberry and install all the necessary things (nodejs and repo-mpd)

curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
sudo apt install -y nodejs mpd

  • Download Plexamp and extract it

wget https://files.plexapp.com/elan/plexamp-v1.0.5-pi.tar.gz
tar -xzvf plexamp-v1.0.5-pi.tar.gz

  • Change the the bundled mpd.conf for the use with snapcast

nano plexamp/resources/helpers/linux-arm/mpd.conf .

  • change audio output in the mpd.conf to a pipe and leave the rest unchanged!!!

audio_output {
type “fifo”
name “my pipe”
path “/tmp/plexfifo”
format “48000:16:2”
mixer_type “software”
}

  • copy it to /etc/ and correct the permissions

sudo cp mpd.conf /etc/
sudo chown mpd:audio /etc/mpd.conf

  • for some systemd-foobar deactivate the mpd.service and the mpd.socket in systemd - otherwise the setup will not survive a restart … we will reactivate it later via rc.local

sudo systemctl disable mpd.service
sudo systemctl disable mpd.socket

  • patch the server.prod.js in /home/pi/plexamp/server/ as mentioned in the post of StalkerSVR (I uploaded an already patched version: server.prod.js.patched.tar.gz (693.4 KB))

tar -xzvf server.prod.js.patched.tar.gz
cp server.prod.js.patched /home/pi/plexamp/server/server.prod.js

  • Move everything to /opt/plexamp (I like my system cleaned up :wink: )

sudo mkdir /opt/plexamp
sudo cp /home/pi/plexamp /opt/plexamp

yes - this results in /opt/plexamp/plexamp/ … for reason - I like to have my files on one place were i find them again

  • create a directory for the server.json and link it to the directory /home/pi/.config/Plexamp

sudo mkdir /opt/plexamp/config
mkdir /home/pi/.config
ln -s /opt/plexamp/config /home/pi/.config/Plexamp
chown -R pi:pi /opt/plexamp

  • copy your server.json from an existing Plexamp Setup to the created directory

scp :~/.config/server.json /opt/plexamp/config/

  • edit the systemd service plexamp.service to use the new directory

nano /opt/plexamp/plexamp/plexamp.service

change the ExecStart parameter to "/usr/bin/node /opt/plexamp/plexamp/server/server.prod.js

ExecStart=/usr/bin/node /opt/plexamp/plexamp/server/server.prod.js

  • copy the systemd service plexamp.service to your systemd directory

sudo cp /opt/plexamp/plexamp/plexamp.service /lib/systemd/system

  1. Configure the server of SnapCast
  • For the first run we create the fifo and the permissions by hand - later (the history command is your friend) we copy the same commands to /etc/rc.local

mkfifo /tmp/plexfifo
chown snapserver:snapserver /tmp/plexfifo
chmod 777 /tmp/plexfifo

  • now we copy the same commands to the /etc/rc.local

nano /etc/rc.local

  • add the following commands

mkfifo /tmp/plexfifo
chown snapserver:snapserver /tmp/plexfifo
chmod 777 /tmp/plexfifo
systemctl start mpd # mpd is started here for some systemd foobar
systemctl start plexamp # plexamp is started here for some systemd foobar

  • open the snapserver config …

nano /etc/default/snapserver

  • … and add the the plexfifo to the server options

-s pipe:///tmp/plexfifo?name=Plex&sampleformat=48000:16:2&mode=read

  1. Start the beast

sudo systemctl daemon-reload
sudo systemctl start mpd
sudo systemctl start plexamp
sudo systemctl restart snapserver

  1. Pray :wink:

  2. If you have done everything right you can fire up a plexamp on your desktop or the plexapp on your phone - start a song, change the output to the plexamp player on your raspberry and enjoy the feeling of having the music everywhere

  3. Troubleshooting
    As always the are minimal mistakes done by everyone (that includes me!). At first - start every service on a seperate console and check for errors

  • for plexamp use the following command as the user pi

/usr/bin/node /opt/plexamp/plexamp/server/server.prod.js

Check for errors like

error: [MPD] Error connecting:Error: connect ECONNREFUSED 127.0.0.1:36600
If thats the case - mpd is not reachable

check you mpd config / disable mpd socket and service

  • for mpd use the command as user pi

mpd --no-deamon /etc/mpd.conf

  • A good hint that something is going wrong is when mpd is not running on localhost:36600 - in that case check if you disabled mpd via systemd (this error costs me 1-2 h)

systemctl stop mpd.service
systemctl stop mpd.socket
systemctl disable mpd.service
systemctl disable mpd.socket
systemctl start mpd.service

If ss -pant tells you that mpd is listening on localhost:36600 mpd is not the show stopper

ss -pant
LISTEN 0 5 127.0.0.1:36600 : users:((“mpd”,pid=487,fd=9))

  • Check your rc.local - is the snapfifo create - are the permissions ok - ist mpd started in the rc.local ?

  • Everything Ok - but I still don’t hear anything - CHeck if you changed to the right output in snapcast :wink:

Kind Regards
ChewyF5

P.S.:
Files i created / used in this HowTo

.

3 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.