How to Stream MPD and Setup Mpdroid

Published 2016-04-28 on Anjan's Homepage

MPD is great for handling a large music collection. It even has a feature where it can stream your music output over http. However, I found that there wasn’t a good guide on setting http streaming up. Furthermore, I found a work-around to a bug in mpdroid that no google search revealed. Therefore, I thought that writing a guide on setting up http streaming would help alot of people out. Here’s what I did to setup mpd and mpdroid:

Installing MPD

Start by installing mpd and mpc on your selected distribution. On debian it would be:

sudo apt-get install mpd mpc

Then, make a new user to run mpd so you don’t have to run mpd as root:

sudo adduser mpdstream

Switch to the new user:

su - mpdstream

Create the files for mpd’s data and config:

mkdir .mpd
mkdir .mpd/playlists
touch .mpd/{mpd.conf,,mpd.db,mpdstate,mpd.log}

Open .mpd/config in your favourite text editor and copy paste the following config in there:

music_directory "/mnt/AAE0DC50E0DC247B/Music"
playlist_directory "/home/mpdstream/.mpd/playlists"
db_file      "/home/mpdstream/.mpd/mpd.db"
log_file      "/home/mpdstream/.mpd/mpd.log"
pid_file      "/home/mpdstream/.mpd/"
state_file     "/home/mpdstream/.mpd/mpdstate"

audio_output {
     type  "alsa"
     name  "whatever you want"
     mixer_type "software"
     mixer_control "PCM"

audio_output {    
    type        "httpd"    
    name        "My HTTP Stream"    
    encoder     "lame"          # optional, vorbis or lame    
    port        "8001"    
    quality     "5.0"           # do not define if bitrate is defined    
#   bitrate     "320"           # do not define if quality is defined    
#   format      "44100:16:1"    

filesystem_charset             "UTF-8"
user                "mpdstream"
password                        "YOURPASSWORD@read,add,control,admin"
bind_to_address         ""

I will only explain the options you will need to change in order to ensure everything works. If you’d like to learn about the other options I entered, please read the documentation for mpd.

music_directory "/mnt/AAE0DC50E0DC247B/Music"

Replace /mnt/AAE0DC50E0DC247B/Music with your music directory.

type "alsa"

Enter your audio output (alsa or pulse).

The second audio output defines the settings for the web output of mpd. Mpd supports playing to multiple outputs so the alsa/pulse output and httpd output can coexist in the same config file.

encoder "lame"

I will only go over how to use lame in this guide as it is the most common, it is the most likely encoder to work with your phone (see mpdroid setup), and it is the easiest to install.

port "8001"

Change this if you want and make note of it.

quality "5.0"

This quality integer is a good compromise for me when it comes to bandwidth used vs. quality.

password "YOURPASSWORD@read,add,control,admin"

Finally, set your password where it says YOURPASSWORD before the "@read,add,control,admin". If my password was spiderman, this line would become:

password "spiderman@read,add,control,admin"

Write and close the config file.

Install lame by running:

sudo apt-get install lame

Make sure you allow the ports for httpd and mpd through your firewall. In my case, the httpd port is 8001 and the mpd port is 6000. So, I ran:

sudo ufw allow 6600/tcp
sudo ufw allow 8001/tcp

Also, if you’d like to use mpd httpd outside of your network, forward these ports in your router.

Make sure no instances of mpd are running by typing killall mpd into the terminal.

Then, type mpd into terminal in order to to start mpd as the user mpdstream.

Setting up Mpdroid

Download mpdroid from playstore

Tap on Default connection settings

For Host, enter the ip of your router if you’re outside your network. If you’re inside your network, enter the ip of the computer you’re running the mpd server on.

For Port, enter your mpd server port (Since I didnt change it in my config, it’s 6600)

Enter the password for your mpd server

For Streaming host, enter the same ip as you entered for Host.

For Streaming port, enter your mpd streaming port (In my case, it’s 8001).

For streaming url suffix enter mpd.mp3 if you’re using lame as this guide describes. Enter mpd.ogg if you’re using vorbis.

Press back a couple times once you are done configuring and it will try to connect to your server.

Once connected, try to play something and tap the bottom bar with the title of the current song playing. Click the three dots on the top right of the screen and check streaming. If sound doesnt play, know that this is a common bug on android. However, I came up with a work-around:

No sound from Mpdroid when streaming

Download vlc from the playstore.

Tap the three horizontal lines on the top left of vlc and tap stream.

For network address, type http://YOUR_STREAMING_HOST_IP:YOUR_STREAMING_PORT/mpd.mp3

In my case, this would be: if I was on my internal network.

Now, when you have a song playing in mpdroid, you can tap the ip of your server to listen to it. You treat mpdroid as the remote to pause/change songs and vlc as the app that plays the streamed data.

Reccomended further readings:

Have a comment on one of my posts? Start a discussion in my public inbox by sending an email to ~anjan/ [mailing list etiquette]

Articles from blogs I follow around the net

These articles/blogs do not represent my own opinions or views.

Todo.txt-more: Efficiently managing your todo list and your time

Todo.txt More: Efficiently managing your todo list and your time Introduction I tend to get fairly enthusiastic when it comes to lists, even more so when there's a chance to optimise my productivity. The end of the year is a time for looking backward an…

via Proycon's website December 31, 2022

The PineTab2 is a new, faster Linux tablet - and it's not alone

In their December update, Pine64 announced the PineTab2, which is the successor to their PineTab from 2018. As a major change, the PineTab2 upgrades the slow A53-based A64 SoC with an A55-based Rockchip RK3566, the same chip that was used for the Quartz64…

via TuxPhones - Linux phones, tablets and portable devices December 19, 2022

I shall toil at a reduced volume

Over the last nine years I have written 300,000 words for this blog on the topics which are important to me. I am not certain that I have much left to say. I can keep revisiting these topics for years, each time adding a couple more years of wisdom and impro…

via Drew DeVault's blog December 1, 2022

Generated by openring