I don't know if this is a mopidy issue or not.
I installed mopidy today and was playing music. I wanted to watch a youtube video noticing I can't. When I killed mopidy it suddenly was working again.
I'm using archlinux. The problem only arises when I use the provided .service file and start it using systemd. When starting it in a terminal, it works fine.
I know at least one other person had/has this issue documented here
Is this a archlinux(systemd) issue or a mopidy one?
Are you using pulseaudio?
yes
Pulseaudio doesn't allow one user to play sound through another users pulseaudio server. If pulseaudio is not started at boot, the first application trying to play sound starts it automatically. So if you play with mopidy first, pulseaudio will be started as the mopidy user and your not able to play sound as your normal user.
A solution for allowing multiple users to play sound is documented here:
https://wiki.archlinux.org/index.php/Music_Player_Daemon/Tips_and_tricks#Local_.28with_separate_mpd_user.29
This is for mpd, so you can ignore the part about mpd.conf. The config for pulseaudio is what's needed. In addition, you need to config mopidy to use the correct pulseaudio server. To do that, put this in your mopidy config:
[audio]
output = pulsesink server=127.0.0.1
I will try that out as soon as I have time.
I still have a question though. Why do I have an issue if I start mopidy using systemd (as my user) but not when I start it myself from commandline? Isn't the same user accessing pulseaudio?
And I think that should definitely be documented somewhere...
Solved it another way.
There is a systemd service file for running it as a local user here
Using this file I have no problems, You could consider adding it here.
Cool, closing this and if someone things we should add something extra to the docs with respect to this please reopen.
I had this problem myself, but the other way around. Mopidy didn't seem to be able to play no matter how I configured the sound. To make it easier to find this solution, I'll post the errors I found in my logs
This one is from the normal output:
ERROR GStreamer error: state change failed and some element failed to post a proper error message with the reason for the failure. Debug message: gstplaysink.c(2758): gen_audio_chain (): /GstPlayBin2:playbin20/GstPlaySink:playsink
With -vvv
to mopedy and gstreamer debugging I found these errors:
WARN alsa pcm_hw.c:1557:snd_pcm_hw_open: alsalib error: open '/dev/snd/pcmC1D0p' failed (-2): No such file or directory
WARN alsa pcm_dmix.c:1022:snd_pcm_dmix_open: alsalib error: unable to open slave
WARN alsa gstalsasink.c:765:gst_alsasink_open:<alsasink0> error: Could not open audio device for playback.
WARN alsa gstalsasink.c:765:gst_alsasink_open:<alsasink0> error: Playback open error on device 'default': No such file or directory
ERROR 2015-02-22 18:26:47,673 [3135:MainThread] mopidy.audio.actor
GStreamer error: state change failed and some element failed to post a proper error message with the reason for the failure. Debug message: gstplaysink.c(2758): gen_audio_chain (): /GstPlayBin2:playbin20/GstPlaySink:playsink
Some of these errors could come from me configuring things the wrong way, but hopefully they will help someone.
Many thanks, trygveaa! I found the trick on the Arch wiki, but I wasn't able to properly configure the pulsesink. (Indeed there seems to be no comprehensive documentation about that.)
@trygveaa I'm really grateful to you. I couldn't find the way how to make pulseaudio working with mopidy. I followed your advice and now it finally works!!
Most helpful comment
Pulseaudio doesn't allow one user to play sound through another users pulseaudio server. If pulseaudio is not started at boot, the first application trying to play sound starts it automatically. So if you play with mopidy first, pulseaudio will be started as the mopidy user and your not able to play sound as your normal user.
A solution for allowing multiple users to play sound is documented here:
https://wiki.archlinux.org/index.php/Music_Player_Daemon/Tips_and_tricks#Local_.28with_separate_mpd_user.29
This is for mpd, so you can ignore the part about mpd.conf. The config for pulseaudio is what's needed. In addition, you need to config mopidy to use the correct pulseaudio server. To do that, put this in your mopidy config: