MPD starts playing after boot

Please report any bug found here

MPD starts playing after boot

Postby Midnight » 22 Mar 2014, 17:40

Hi,

it seems MPD automatically starts playing after boot, even if it was paused/stopped before.

Note: I'm switching it off without shutdown command.
User avatar
Midnight
Moderator
 
Posts: 141
Joined: 19 Feb 2014, 14:46

Re: MPD starts playing after boot

Postby dopus » 22 Mar 2014, 19:00

Same here.Mabye it is fixed in the next release.
dopus
 
Posts: 11
Joined: 14 Mar 2014, 07:58

Re: MPD starts playing after boot

Postby tc-fi » 23 Mar 2014, 13:59

same here----starts playing after boot!
tc-fi
 
Posts: 43
Joined: 21 Jan 2014, 03:12

Re: MPD starts playing after boot

Postby Midnight » 23 Mar 2014, 14:13

It ruins my last.fm profile because it submits tracks everytime I turn on my stereo (which also turns on the rest of my multimedia stuff) :evil: ;)
User avatar
Midnight
Moderator
 
Posts: 141
Joined: 19 Feb 2014, 14:46

Re: MPD starts playing after boot

Postby junaling » 17 Apr 2014, 22:06

This happens to me when I do a shutdown through ssh while still playing, however if I stop/pause the current song before issuing the shutdown it does not.
junaling
 
Posts: 8
Joined: 02 Apr 2014, 05:56

Re: MPD starts playing after boot

Postby Midnight » 05 Jun 2014, 15:41

junaling wrote:This happens to me when I do a shutdown through ssh while still playing, however if I stop/pause the current song before issuing the shutdown it does not.

This is the intended behaviour and therefore there is a MPD state file in the config:
state_file "/var/lib/mpd/mpdstate"


Maybe there should be an option to disable the state file completely.
User avatar
Midnight
Moderator
 
Posts: 141
Joined: 19 Feb 2014, 14:46

Re: MPD starts playing after boot

Postby LosHermanos » 12 Jul 2014, 09:01

Hi there,

Mine doesn't start playing at all at boot, whatever I do. I am playing with 0.3 (0.2 doesn't work at all on my Pi).
I also noted that the state file isn't changed anytime. I thought playing with the state file might get me autostart, but I can't get it to work.
LosHermanos
 
Posts: 1
Joined: 12 Jul 2014, 08:33

Re: MPD starts playing after boot

Postby Midnight » 16 Jul 2014, 17:24

Midnight wrote:Maybe there should be an option to disable the state file completely.

BTW: after disabling the state file mpd also loses it's playlist after restart, so this is not an option.
User avatar
Midnight
Moderator
 
Posts: 141
Joined: 19 Feb 2014, 14:46

Re: MPD starts playing after boot

Postby waves » 18 Jan 2015, 00:36

Yes this is a bad bug. Imagine that a user leaves RuneAudio on with high volume but in pause mode and there is e.g. a brief power outage that involuntarily reboots the pi during the night. Both the user and the neighbors would get a not so pleasant awakening at 3 a.m. :)

I work around the bug with a script that runs at boot (set up with systemd) and repeatedly executes the "mpc stop" command for around 30 seconds, since the RA/mpd seem to resume play with a little delay. That works. But I hope the bug will be fixed properly.
waves
 
Posts: 121
Joined: 31 Dec 2014, 10:33

Re: MPD starts playing after boot

Postby daymz » 23 Jul 2015, 02:43

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 starts

When 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 script

Even 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 setup

Go 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!
daymz
 
Posts: 19
Joined: 25 Feb 2015, 02:19

support RuneAudio Donate with PayPal

Next

Return to Bug report

Who is online

Users browsing this forum: No registered users and 1 guest