I've been enjoying using Mopidy and ncmpcpp as my music player.
On Ubuntu though I encountered a persistent problem:
However, it kept failing to connect to PulseAudio. It seemed to be unable to make any sound play back, unless I manually killed pulse, after which it could start playing.
Yes I had followed all the instructions. I had changed Mopidy's config as well as PulseAudio's config. I tried everything, setting PulseAudio to be as permissive as possible (allowing remote connections etc).
The solution, as far as I can tell, for my standard Ubuntu 18.04 is: you should not do both of these things. This is because if you run as a service, you're running something that starts up as soon as the computer boots, and doesn't use your login userid. PulseAudio, however, does not run on startup, but is part of your login session. So it simply isn't there for Mopidy to connect to, until you log in. (I still don't know why that should mean it's unable to connect, even after logging in. I suspect it's because it's running under a different user id.)
So here's what I've got now: instead of running Mopidy as a service (using
mopidyctl to control it), I'm running it as a "startup application", i.e. something that runs on my own user account as part of my graphical desktop login. On Ubuntu there's a program called "Startup Applications" that you use to add/remove things easily. The one small drawback with this approach is that the music player won't be running if the machine reboots and I haven't logged in yet. However, there's usually a logged-in session running.
You might think that "running as a service" and "outputting audio via PulseAudio" would be compatible, especially as they're both listed on the same piece of documentation on the Mopidy website. Perhaps there's an extra trick (e.g. some permissions) that my system needs. But this non-service setup works fine.