Introduction: Linux Music Server Controlled by an Android Device
A Linux computer that acts as a music server for files like MP3 and FLAC. It will also play Pandora radio and everything can be controlled by an Android device so there's no need to connect the computer to a monitor.
Linux computer (personally I'm using a Raspberry Pi, http://www.raspberrypi.org/ for 35$)
A device running Android, like a phone or tablet
A local network where the Android device and Linux computer are connected
An external sound system or speakers connected to the computer
A couple of minutes to set everything up
There are many different Linux distros out there and this guide will explain how to set it up on Debian based distros (such as Ubuntu, Linux Mint, Raspbian etc.). It's of course possible to set up on any distro but depending on what package manager the distro uses, the commands will be different. The guide will assume that you have already installed Linux on your computer.
Step 1: MP3, FLAC Etc. (MPD)
MP3, FLAC etc. (MPD):
For music files like MP3 and FLAC we will use MPD, http://mpd.wikia.com/wiki/Music_Player_Daemon_Wiki. This is a daemon that can be controlled remotely by a number of different clients. It's included in most major Debian based distro's repositories so all you need to do to install it is open a terminal (shell) on the linux computer and write:
sudo apt-get update && sudo apt-get install mpd
After it has installed we tell it where to look for our music files by editing the configuration file:
sudo nano /etc/mpd.conf
Scroll down to the line "music_directory" and change the path within the parentheses after this line to the path where your music files are, for example:
Then scroll down to the line that says
And change it to the ip or host of the computer on the local network, if you don't know what your ip is you can open a new terminal and write:
Look for the line that says "inet addr" followed by something similar to "192.168.0.2". Those are the numbers that you should add instead of "localhost" in the config file:
Normally this is everything you need to do to get MPD working and the sound output defaults to the default ALSA sound card. If you are using a different sound framework or want to change the sound card you will have to change the "Audio Output" section of the config file yourself (there are too many combinations possible to list them all here), there are examples included in the config file and more information can be found at http://mpd.wikia.com/wiki/Configuration.
After you have edited the config file, close it by pressing "ctrl + x" and choose "y" to save the file. Then restart MPD by writing:
sudo /etc/init.d/mpd restart
Controlling MPD (MPDroid):
To control MPD we will use an Android app called MPDroid. You can search for it on Google Play or use this link: https://play.google.com/store/apps/details?id=com.namelessdev.mpdroid
Install it as normal on your Android device and start it up. Go to the settings dialog and select "WLAN based connection". Choose the network that you are connected to and select "Host". Here you enter the ip address of the Linux computer (same as we entered in the config file above).
Go back to the main settings dialog and tap "Update". After a while the music should show up in the file list.
Step 2: Pandora Radio (pianobar)
Pandora, for those not familiar with it, is an internet radio where you can choose genres or create stations based on a song or artist and it will play similar music. It is a US only service but with these instructions you can play Pandora from anywhere in the world.
Pianobar, see http://6xq.net/projects/pianobar/, is an unofficial flash-free Pandora command based client. It is easy to set up with a proxy and also removes the ads from Pandora (to support Pandora you can register for a Pandora One account, it will give you higher quality audio, see http://raspberrypiserver.no-ip.org/pianobar_pandora_remote_control.html for setup instructions for Pandora One).
Make an account on http://www.pandora.com. If you are not in the US you will need to connect through a proxy during the registration process, there's an extension for Chrome and Firefox called media hint (https://mediahint.com/), which will make the process easy. Just install it and browse to Pandora. You will also have to enter a US zip code (any zip code will work...).
Install pianobar on the Linux computer - open up a terminal (shell) and write:
sudo apt-get install pianobar
Then set up a config file for pianobar:
My config file looks like this, the login details (e-mail and password, to Pandora) are necessary, as well as the full path to the event command file (change the username "user" in bold to suit your system):
tls_fingerprint = 2D0AFDAFA16F4B5C0A43F3CB1D4752F9535507C0
user = firstname.lastname@example.org
password = mypassword
event_command = /home/user/.config/pianobar/eventcommand.sh
If you are outside the US you need to connect through a proxy server, see https://hidemyass.com/proxy-list/search-225511 or http://spys.ru/free-proxy-list/US/ for a list of free proxies, and add this line to the config file (change the numbers to a working proxy server):
control_proxy = http://165.225.xxx.xxx:80
Then just run the following command to download the eventcommand file, make it executable and make the fifo:
cd ~/.config/pianobar && wget http://raspberrypiserver.no-ip.org/eventcommand.sh && chmod +x eventcommand.sh && mkfifo ctl
You can test the setup by running the command "pianobar".
To control pianobar from our Android device we will use an app called Pianobar (Pandora) Remote. Search on Google Play or use this link: https://play.google.com/store/apps/details?id=com.pianobar.remote or http://raspberrypiserver.no-ip.org/pianobar_pandora_remote_control.html for an off-market apk file.
To connect to pianobar we will need SSH set up on the Linux computer. This is already installed and set up on most distros, if not you can install it by entering the following command in a terminal:
sudo apt-get install openssh-server
Start the app and enter the login details to the Linux server, the host/ip is the same as we used in step 1 and the username/password are the same as you use to login on your Linux computer. Tap "Login" and select the station list (bottom left) to get started.
We have a be nice policy.
Please be positive and constructive.