Alternatively you can try this to add to /etc/rc.local
Use your choice of editor to open a new file and save it as startup.sh somewhere you can find it, I used /home/pi/startup.sh
Copy and paste the following into the document - you will need to put your own playlist details in near the bottom of the script.
#!/bin/bash
INI__musicbox__autoplaymaxwait=120
echo “Waiting for Mopidy to accept connections…”
waittime=0
while ! nc -q 1 localhost 6600 </dev/null;
do
sleep 1;
waittime=$((waittime+1));
if [ $waittime -gt $INI__musicbox__autoplaymaxwait ]
then
echo “WARNING: Timeout waiting for Mopidy to start, aborting”
break;
fi
done
if [ $waittime -le $INI__musicbox__autoplaymaxwait ]
then
echo “Mopidy startup complete, playing $INI__musicbox__autoplay”
mpc add spotify:playlist:put your playlist name here
mpc play
fi
Save and exit
Give it the correct permission
sudo chmod 755 /home/pi/startup.sh
Try and run it in a terminal
sudo /home/pi/startup.sh
You should get a line saying something like
“Waiting for Mopidy to accept connections…
OK MPD 0.19.0
Mopidy startup complete, playing”
If thats working then
sudo nano /etc/rc.local
and at the bottom, but before exit 0 add
sudo /home/pi/startup.sh
then exit, save and reboot to see if it works.
Tried both varieties on mine this evening and both seem to work, hope it does for you.