OK, I`ve spent the entire day on this because I just hate the auto-play on boot behavior. I do want the state saved to keep the existing playlist, but in my case, resuming play on boot makes no sense at all (ex: power outage at night - boom, sound system starts blasting music I was listening to some other day)
The fix is in several parts:
1) make sure that the mpdstate file is on "pause" at startup
2) remove a play command in orion_optimize.sh
The following tutorial was done on RuneAudio 0.3 for Raspberry PI.
Part 1 : Change mpdstate before mpd startsWhen mpd quits, it saves it states to the state file (/var/lib/mpd/mpdstate). If your device rebooted while it was playing, we will want to have it chagned to pause in order ot avoid mpd restart play.
Create a new script and save it somewhere (example here: /home/user/mpd_state_pause). The script will modify the mpdstate file so that the mpd state is always "paused"
- Code: Select all
#!/bin/sh
# Modify MPD's state file to ensure current state is "pause"
sed -i 's/^\(state: \).*/\1pause/' /var/lib/mpd/mpdstate
Now, let's run that script before starting mpd. The best way is to use systemctl's ExecStartPre directive. Modify /usr/lib/systemd/system/mpd.service to add the ExecStartPre line below: (don't forget to change the path of the script to the location you chose earlier)
- Code: Select all
[Unit]
Description=Music Player Daemon
After=network.target sound.target
[Service]
ExecStartPre=/home/user/mpd_state_pause
ExecStart=/usr/bin/mpd --no-daemon
[Install]
WantedBy=multi-user.target
Part 2 : Fix the orion_optimize.sh scriptEven though I did Part 1, I could see in the UI that MPD was being restarted, and oh no, play resumed. It took me a freakin' while, but I eventually found out that /var/www/command/rune_SY_wrk was calling /var/www/command/orion_optimize.sh, and at line 159, that script was calling "mpc play".
Comment out "mpc play" at line 159.
- Code: Select all
sndusb_profile() {
local "${@}"
mpc pause > /dev/null 2>&1
sleep 0.3
modprobe -r snd-usb-audio
echo "options snd-usb-audio nrpacks=${nrpacks}" > /etc/modprobe.d/modprobe.conf
sleep 0.2
modprobe snd-usb-audio
sleep 0.5
#mpc play > /dev/null 2>&1
#mpc pause > /dev/null 2>&1
#######mpc play > /dev/null 2>&1
}
Part 3 : Test your setupGo to the RuneAudio web UI, put a couple tunes/web radios in the queue, hit Play. Now reboot the device.
Once rebooted, the queue should still contain all your files, but play will not resume. It will be paused.
Enjoy!