Stream from mpd to smartphone or the entire music collection in your pocket
I am a fan of listening to music on the road and at work, while accumulating a considerable collection of music in lossless on my home computer. I would like to have access to music not only at home but also on a smartphone. Limited memory does not allow me to fit my entire collection, no matter what memory cards I expand it. Yes, and I do not want to spend memory on this, because there are many more things that I want to write down there. Before, I tried to manage to collect everything I want to listen to before I go to work, convert it to a compressed format (I think that lossless on a mobile device is surplus) and record it on a mobile device. But as always did not, and often had to be content with the old hackneyed playlist. Then I got unlimited mobile Internet and I completely abandoned the "throwing" of music, began to listen to Internet radio stations. I had to constantly jump between the stations, and even these DJs are constantly wedged in. And then I got the idea to make my own personal stream, with blackjack and ... all the consequences.
It was decided to install on the home server mpd, on a smartphone, an application for listening to Internet radio and an mpc client in order to select music on the fly. If you are interested in how, please, under cat.
In this article I will describe how to do this on a server running Ubuntu and an Android smartphone.
I will immediately list the advantages:
- All music collection available
- Mobile device memory free
- You can choose the optimal bitrate for the mobile device and do not need to convert anything
And disadvantages:
- Not everyone has unlimited 3G
- A delay of about 5 seconds when rewinding a track (determined by the size of the buffer)
- Not everyone has a home server
The latter drawback can be disputed, since it is not necessary to have a PC server for this. All this can be deployed on a home access point with a USB HDD connected, for example, on TL-MR3020, DIR-320, TL-WR1043ND ... and so on, this list can be continued for a long time, the main thing is the presence of a USB port for connecting the HDD and supporting alternative firmware (OpenWRT , DD-WRT, firmware from Oleg, etc. By the way, you can still connect a USB audio card to the point and get a home media center). If there is interest, I can write a detailed how-to on settings, for example, on OpenWRT.
Back to the main topic, let's get started on setting up on Ubuntu Server 12.04.
MPD
Install the packagesudo apt-get install mpd mpc
Next, you can install the codecs if necessary.
Now configuration
sudo nano /etc/mpd.conf
I will list only the required parameters.
# Каталог с нашей музыкой
music_directory "/data/music"
# Отвечать на запросы извне
bind_to_address "0.0.0.0"
# Настройка стрима
audio_output {
type "httpd"
name "My HTTP Stream" # Имя
encoder "vorbis" # Выбираем кодек
port "8123" # Удобный для нас порт
bitrate "128" # Битрейт, зависти от наших личных предпочтений и возможностей провайдера
format "44100:16:2"
}
Now restart the daemon
sudo service mpd restart
Next, we need to update the music database, for this we will command in one of the terminals
sudo tail -f /var/log/mpd/mpd.log
to follow the update process, and in anothermpc update
Now we have a server ready to broadcast music to our mobile device. But I prefer not to keep open ports on the server (except for one), so I use OpenVPN.
VPN
Configuring a VPN is completely optional, it is a nice option that gives more privacy. There are many articles on setting up a VPN server. I just want to say that there is a wonderful client for Android devices OpenVPN Settings (requires root, OpenVPN Installer, BusyBox, sometimes TUN.ko Installer). And for Android version> 4, there is an even more wonderful OpenVPN for Android client. All applications are available on Google Play. OpenVPN earned on all my devices, though some didn’t immediately.Android
Let's move on to the smartphone settings. We need a client for mpd and an “Internet radio” capable of adding a custom stream url to the playlist. All these applications have Google Play, there is a decent choice of both. I made a choice in favor of the MPDroid client, in it I liked the interface and XiiaLive ™ - Internet Radio. For the sake of choosing the first comer with the ability to add a custom stream url.I must say that MPDroid allows you to play the stream broadcast by mpd itself, but I was not satisfied with the stability (freezes and crashes) and the delay when switching tracks. In view of this, I opted for a third-party player application. Someone may not like that you have to use two programs at the same time, but it suits me perfectly. Perhaps in the future they will improve MPDroid and it will become possible to listen exclusively through it.
Configuring these applications is not difficult, for MPDroid, when you first start, select Default connection settengs, enter the server address in the Host, Port field by default. We check the contents of the library, set the track to play. Now run XiiaLive, go to your “favorites”, add the URL, enter http: \\ 10.0.0.1:8123, where 10.0.0.1 is the address of our server.
Enjoy listening, and stable connection.
PS You can also look towards Google Play Music, they allow you to upload music to the cloud.