Via its extensions, Mopidy is capable of playing music from sources like Spotify, sound cloud, and google music to mention a few, and the playlist etc can be controlled through client interfaces running on phones tablets or PCs using MPD web clients. You can now listen to Spotify with your Raspberry Pi and control it from your phone It’s really nice to use. Related Questions. Is there a way to play Spotify on Raspberry Pi for free? No, Spotify is a premium service, you need a paid account to use it. There is a free trial for 30 days if you want to try it, but that’s all.
I always wanted to have an audio multiroom, which would allow me to play the same music in all rooms, but also provide the ability to control each room separately (on/off, volume, etc.). Obviously, I could buy one of the existing systems like Denon Heos, but then I would need to remove/sell my old audio equipment, which is working perfectly fine. I could also buy Chromecast Audio and create an audio group - but it seemed like a “too easy” solution. Fortunately, one of the presentations from this year code.talks conference gave me the inspiration and direction for building my own multiroom system, based on Raspberry Pi devices.
I started with some requirements:
Broadcasting software
After some research and testing, I think that Snapcast is currently the best solution for this use case. Here is why:
Music source software
Although you can connect many players to Snapcast, I chose to use Mopidy. Such combination was already tested pretty well by other geeks. Mopidy is also quite new open source software with a vibrant community. It supports not only Spotify but also Soundcloud, Google Play and mp3/flac files. Integration with Snapcast is just a matter of one line in the configuration.
Overall solution
After some struggling, the overall solutions looks like below:
One Raspberry Pi is working as a Snapserver and Snapclient at the same time, with Mopidy service for music management. The other Pi’s are simple clients, that could be added/removed dynamically, they just need to be in the same network.ProblemsOf course, not everything works like in the tutorials. I want to share some of my findings, maybe it can save your time.Raspberry Pi sound output qualityWith Raspberry Pi you usually have 2 audio outputs: HDMI and mini jack. You can easily switch between them thanks to raspi-config, but the jack output has some problems with sound quality. So after installing the Raspbian system, I strongly recommend putting a magic line `audio_pwm_mode=2` to `/boot/config.txt` file. This way you will not waste a lot of time with wondering why audio stream with 48000Hz sampling sounds like music played from a megaphone.Raspberry Pi time synchronizationIf you notice a strange behaviour with losing sound stream on Snapclient devices, this is probably because of time synchronization mechanism on Raspbian system. In my case after Raspberry Pi boot, I was losing the sound stream for about 1 minute, after restarting the device. It’s the `Systemd-timesyncd` service caused it. This problem is a known issue with a few workarounds:
![]() TroubleshootingI suppose it is obvious, but in case of any problems check one thing at a time: start with Mopidy, then check Snapserver using only a single wave file as a source and then Snapclients. In most cases, service logs are enough to see what is going on, so don’t forget about the `journalctl` command.User interfaceAs usual with open-source, the biggest problem was with the UI. It must be useful not only for geeks, but for normal human beings as well. At this point I tested 2 mobile apps:
Spotify playlistsIf you are a single Spotify user, then everything is straightforward. The problem is when you have different Spotify accounts than e.g. your wife and you both want to play some of your favourite Spotify playlists. There are a few solutions for that. The easiest - your account could follow playlists from the second one. If you don’t want to pollute your Spotify search history with some crazy music, you could also create a separate account for the multiroom system and follow playlists from both accounts. Probably the only good reason for that is when you have a free slot on Spotify Family subscription. You can also use the multiroom via Mopify web client. Mopify has a very interesting feature. After entering the configuration page anyone can (temporary) synchronize his/her Spotify account with the Mopify session and have access to all Albums, Playlist, etc., without the need of following anything. The user experience on desktop is great, on mobile it’s only ok - probably it will never beat the native app.SummaryFrom my perspective, all requirements were met. Maybe except the last one. If I would add my free time for this project, then Chromecast option will be much cheaper. On the other hand, I learned a lot about Raspberry Pi and I have a lot of ideas how to extend the system to provide features completely different than only playing music.Introduction
I’ve finally managed to get a Raspberry Pi. I’ve already thought a long time of buying one,but because of missing ideas what to do with it I didn’t buy one.A school project came by which served the perfect reason to finally buy one (hint: self made monitoring camera)and now I’m lucky to have one.
Mopidy and stuff
So what is running on my RPI now?Currently there is a raspian installed and except the whole music-server-software nothing special.I run mopidy with mopidy-spotify, mopidy-spotify-tunigo and mopidy-mopify.
So what are all these things?Mopidy is a mpd server which simply stands for music player daemon.On there website is written: Download game clash of war mod apk. Best pdf app reader mac.
Mopidy is an extensible music server written in Python.
And thats it, no more no less. Without anything else mopidy can play music from your disk.Mopidy-spotify is the bridge between mopidy and spotify which enables you to play all kind of thingsfrom spotify. You can play and manage your play lists, favourite artists, songs, albums and search for all these things.Mopidy-spotify-tunigo is to enable the browse feature of spotify, like genres, browse featured play lists or new releases.Mopidy-mopify is just a web front end to interact with mopidy in the style of spotify. This way I can control mopidy via a browser from every device on my network.There are tons of other web front ends out there for mopidy you can have a look here.It is also possible to connect via a CLI-client. I often just use ncmpcpp which is a very wide used terminal music player.Ncmpcpp simply stands for ncurses music player written in C++.There is also ncmpc which is not so feature rich.
Hands on
So what do we have to do to get this all to work?
Surprisingly not much. I’ve installed it two times - because the first time I’ve fucked up - and the second time took me only one hour, including the installation of the operating system.
I assume that raspian is already set up correctly.
What we have to do to install mopidy:
Now we should set some configuration on /etc/mopidy/mopidy
/etc/mopidy/mopidy.conf .There should be a default configuration file already in place.Either add oder adjust these lines under http like this:
This tells mopidy to enable the http extension.
0.0.0.0 tells mopidy to accept connections from every hostname/ip and the port is self describing.
Mopidy Spotify Free Download
Now we need the local ip address of the Raspberry Pi.To get it simply type
ifconfig in your terminal on your Raspberry Pi.
The output should be something like this:
ifconfig
In line two, after inet, you see it’s ip. If you connect via wireless lan it would be in line 29.
If you now type
sudo service mopidy start into your terminal and head to 192.168.2.115:6680 https://yellowbarcode171.weebly.com/laptop-skins-for-mac.html. in this case. I will use this ip address in the rest of this article.Just exchange it for you ip.
You should already be able to see this:
At next we want to install
mopidy-spotify Spotify premium mod old apk.
We need to adjust our mopdiy configuration again.Just add these lines at the end ofthe file.
/etc/mopidy/mopidy
The client id and secret is easily obtainable via this link. Click on login with spotify and after you logged in the data appears in the text field.If you want to configure more like the amount of search results for example have look at the readme of the mopidy-spotify.
Now we want to install
spotify-tunigo :
Hue philips app mac. The configuration is rather simple:
/etc/mopidy/mopidy
Now all we need is
mopify :
We need
pip for that - the python package manager- but fortunately raspian has it already installed.
If it’s not already installed on your system you can install it on an ubuntu like system with:
Again a really simple configuration:
Mopidy Plex/etc/mopidy/mopidy
And everything should be set up correctly.
Now restart mopidy as a service:
sudo service mopidy restart .
Open your browser again at
192.168.2.115:6680/mopidy .
We can see that
mopify is set up correctly. Click on it and see:
Go to
services in the navigation and enable the sync service by simply clicking on it.When you hover over it you can go to settings and enable synchronization of your spotify credentials as well.Next enable the spotify service, maybe you have to log in again.
And that’s it. If you now go to
192.168.2.115:668/mopify you should see some cool stuff like this:
If you didn’t see the welcome screen to load playlists and in the bottom left corner that spotify is disconnected you just need to reload if your sync settings are set up correctly
If you want to connect via ncmpcpp to your Raspberry Pi you just need to run:
ncmpcpp --host 192.168.2.115 --port 6680 or set some config values for ncmpcpp.
Now to test your sound simply put speakers or headphones in the 3.5mm audio output.Then type:
aplay /usr/share/alsa/speaker-test/sample_map.csv If you can hear something everything is fine,if not try to run sudo raspi-config go to advanced options, audio and force the output through the headphone jack.
If this is working your should be able to simply play sound through mopify. :)
Control
You can control this little thing with a browser.Even with a mobile phone it is quite good usable.But of course there are other methods too.
You can install
mpc on your Raspberry Pi with sudo apt-get install mpc And make a key binding - depending on your desktop environment / window manager - to run ssh pi 'mpc next|prev|toggle|play|pause' .
![]()
I have three scripts for toggle, next and prev which are triggering different players/tools regarding what is currently running.You can see them here:
toggle
next prev
You could set up a reverse proxy to only need to enter a specific URL without ip:port or add this ip to your
/etc/hosts file with a hostname and only need to write hostname:ip.But that’s up to you.
ResourcesMopidy Pandora
This whole setup doesn’t need much system resources.This is a screenshot of
htop while playing music, so not even in idle mode.
I’ve never noticed the ram usage to be more than 115MB and processor usage and load average were always not noticeable.So if you are running anything else on your Raspberry Pi and are in doubt that will it use to much performance I think this is not the case.
Automation
To not need to update manually I simply added a little cronjob which runs updates every night at 1 AM, pauses music if playing and restarts the mopidy server. Spotify direct download.
DrawbacksMopidy Windows
Of course there are some drawbacks everywhere and this is no exception.The most important drawback is that you can’t play playlists.You can play artists, tracks, added tracks from your library(which would be one playlist), radio stations but simply no fucking playlists.This is an issue in
libspotify currently as far as I know and not an issue with mopidy or mopify.Before I had playlists for artists and some mixed ones. Now I simply follow the artists and play them from there.
Also the sound is not very nice from the Raspberry Pi’s headphone jack. You will notice quiet disturbing noises.To end this I simply bought a cheap external USB sound card which I plugged in, put the speaker in it and it worked out of the box.You can get one for 5 to 20 Euros, for example this one.
PICS
Thats all, have a niec day.
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |