Using a Raspberry Pi with Android phones for media streaming with UPnP / DLNA

Edit, 2013-07-21: Please note there is now a completely updated (and simpler) blog post on this subject.

This summarises and completes my previous posts on configuring a Raspberry Pi to play music streamed from another computer in the house, using Android phones as remote controls.

There is quite a long discussion below and also an area on the Raspberry Pi forum for discussing this solution.

What we are aiming for

A music system with your music stored on a server and played through your Hi-Fi via the Raspberry Pi, all controlled by multiple, synchronised Android phones/tablets. In addition you can play music from the server on your phone either in the house or anywhere else. This is similar to using Apple’s AirPlay system but uses free software and open standards.

With any luck your initial outlay will only be about £45. The end result will be similar to the systems from Sonos and Squeezebox costing loadsamoney. Further additional devices to play music through another Hi-Fi or TV would also be £45.

What you need

  • A Raspberry Pi
    • I got mine with a case from ModMyPi for £35
  • A wireless USB dongle (or wired ethernet connection near your Hi-Fi)
  • A micro-USB power supply (most phones use these)
  • An SD Card (2GB minimum) – perhaps an old one from a camera?
  • An SD Card reader/writer – often built in to a computer
  • Your music available on a linux server (e.g. CDs ripped to MP3 files) – this could be replaced with e.g. a NAS device or a Windows machine
  • An amplifier with a 3.5mm auxiliary input and speakers (perhaps a TV sound bar?)
  • At least one Android device
  • Some sort of router / wireless network to connect the media server to the Raspberry Pi
  • You might need a USB keyboard and a TV/monitor to do the initial set-up (hopefully you have these lying around)

Note: these instructions assume you have your music on a linux server, but it’s also possible to get all the necessary software on one Raspberry Pi and just point it at a NAS (or, indeed, plug a USB drive in directly). See comments for some more suggestions.

Instructions

Install Debian Wheezy on the Pi

The Raspberry Pi comes with no operating system (OS). The first thing to do is to download one and put it onto the SD card. These instructions assume you are using the Debian Wheezy image (I have checked these instructions work with 2012-12-16-wheezy-raspbian.zip) from the Raspberry Pi site. There are brief instructions there and detailed instructions at elinux.org.

Once you have the OS on the SD card, put it in the Raspberry Pi, plug in your keyboard and TV (via the HDMI or composite video sockets), plug in the micro-USB power supply and turn it on.

Getting the Pi on the wireless network

You can of course skip this if you’re just going to plug it in with an ethernet cable.

Different wireless dongles use different drivers and different home networks have different security settings. It’s therefore pretty tricky to describe how to do this in a generic way but I can give you some pointers.

The lsusb command shows you what USB devices are plugged in. The 4th one on the list below is the Wi-Fi dongle.

$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter

I didn’t have to edit the /etc/network/interfaces file. It was already how I needed it, namely:

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

Amongst other things, this says that the wireless dongle can be plugged in and out when you like, it is configured with DHCP (so it gets an IP address and hostname automatically from your router) and that the password and other security settings for your Wi-Fi can be found in the /etc/wpa_supplicant/wpa_supplicant.conf file.

By typing the command “sudo vi /etc/wpa_supplicant/wpa_supplicant.conf” you can edit the file (replace “vi” with “nano” if you like your text editors to help you out a bit). For me I needed to add these lines:

network={
  ssid="your_ssid_goes_here"
  scan_ssid=1
  proto=RSN
  key_mgmt=WPA-PSK
  pairwise=TKIP
  psk="this is where your secret passphrase goes"
}

Your configuration depends on what Wi-Fi security settings you have on your router: the above work for “WPA2 personal” with “TKIP+AES” for the WPA algorithm with a WPA shared key. There’s more info to be found by typing “man wpa_supplicant.conf”.

At this point, typing “ifconfig” will show you the configuration of “eth0″ (the ethernet interface with the cable in), “lo” (a dummy interface) and “wlan0″: the new wireless interface.

wlan0     Link encap:Ethernet  HWaddr 00:01:02:03:04:05
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

At this point you should probably also configure your router to provide the Pi with an IP address via DHCP (it may do this automatically). I use DD-WRT on my router which lets me assign it a static IP address and a hostname as well. Again, it’s a bit beyond the scope of this post to explain all that but you may need the Wi-Fi dongle’s MAC address which is called the “HWaddr” in the ifconfig output.

If you then do a “sudo ifdown wlan0″ and a “sudo ifup wlan0″ to take the interface down and bring it up again then with any luck, on executing “ifconfig” again you’ll see an additional line showing that your router has assigned an IP address to the Wi-Fi dongle:

wlan0     Link encap:Ethernet  HWaddr 00:01:02:03:04:05
          inet addr:192.168.1.99  Bcast:192.168.1.255  Mask:255.255.255.0
          etc, etc... (addresses changed to protect the innocent)

Installing software on the Pi

Now the Raspberry Pi is on the wireless network, you can disconnect it from the TV and keyboard and put it next to the Hi-Fi. Connect it to the auxiliary input of the Hi-Fi with a stereo audio cable (3.5mm jack like headphones use) and power it up again.

Log in to the Pi from another computer using SSH (username “pi”, password “raspberry”). I use PuTTY from my Windows laptop which does the job nicely. You can then type in comfort at your laptop rather than sitting on the floor by the TV. Incidentally, with PuTTY you paste by clicking with the right mouse button (and copy just by highlighting with the left). If you’re on a Windows machine therefore you can copy and paste from this blog post using Ctrl-C to copy and right-click in PuTTY to paste.

The first thing to complete the set-up of the Pu and update all the packages already installed on the Pi to the latest versions:

$ sudo raspi-config
$ sudo apt-get update
$ sudo apt-get upgrade

The first command runs a config utility that lets you choose your country, keyboard, etc and also lets you choose to stop the Pi booting straight into a desktop which we don’t want. The next gets the latest list of packages and the third command updates existing packages to the latest versions found on that list. This will take a little while.

We then need to install gmrender-resurrect which is a UPnP “renderer”. That is, it plays (renders) music files when told to via the UPnP protocol. It is not provided as a pre-built package so we also have to compile it and manually install all the prerequisites.

# install all the packages we'll need

$ sudo apt-get install git automake libglib2.0-dev gstreamer0.10-alsa gstreamer0.10-tools libgstreamer0.10-dev libupnp-dev libxml2-dev gstreamer0.10-ffmpeg gstreamer0.10-plugins-base gstreamer0.10-plugins-good gstreamer0.10-fluendo-mp3 gstreamer0.10-pulseaudio pulseaudio

# Now get the latest gmrender-ressurect using git

$ cd
$ git clone https://github.com/hzeller/gmrender-resurrect.git
$ cd gmrender-resurrect

# build and install gmrender

$ ./autogen.sh
$ ./configure LIBS=-lm
$ make
$ sudo make install

gmrender uses GStreamer to play sound and GStreamer uses ALSA. For some reason, the sound quality through GStreamer at this point is really bad. To get it sounding good we need to direct the sound through the PulseAudio system (which then uses ALSA). To make GStreamer use PulseAudio rather than directly using ALSA you need to do the following configuration:

$ gconftool-2 -t string --set /system/gstreamer/0.10/default/audiosink pulsesink
$ gconftool-2 -t string --set /system/gstreamer/0.10/default/audiosrc pulsesrc

Note that these commands are executed as the “pi” user and only apply to the “pi” user. If you later run gmrender (or GStreamer directly) as another user (such as root) then the sound quality will be bad again as PulseAudio won’t be in the stack.

To get PulseAudio to start on boot and to allow the “pi” user to access it, two more changes are required:

  1. Edit /etc/default/pulseaudio and change the first uncommented line to “PULSEAUDIO_SYSTEM_START=1″. This is not recommended but it works in this case.
  2. Execute the command “sudo adduser pi pulse-access” to add the pi user to the pulse-access group so that it is permitted to use PulseAudio.

You’ll also need to turn the volume up on the Pi. To do this, run “alsamixer” and press the up arrow cursor key until the volume display gets to the top (if this isn’t doing anything then it may be muted: press “M”). Then press the Esc key to exit. To then save this configuration for the next time the Pi boots, type “sudo alsactl store” which updates the /var/lib/alsa/asound.state file.

2013-01-91 Edit: I’ve written much more about configuring ALSA on the Raspberry Pi here.

To make gmrender start when the Pi is turned on, create the file /etc/init.d/gmediarenderer (as root) with the following contents (e.g. using vi or nano):

#!/bin/sh

### BEGIN INIT INFO
# Provides: gmediarender
# Required-Start: $remote_fs $syslog $all
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start GMediaRender at boot time
# Description: Start GMediaRender at boot time.
### END INIT INFO

USER=root
HOME=/root
export USER HOME
case "$1" in
start)
echo "Starting GMediaRender"
start-stop-daemon -x /usr/local/bin/gmediarender -c pi:audio -S -- -f "Raspberry" -d
;;
stop)
echo "Stopping GMediaRender"
start-stop-daemon -x /usr/local/bin/gmediarender -K
;;
*)
echo "Usage: /etc/init.d/gmediarender {start|stop}"
exit 1
;;
esac
exit 0

Then do:

$ sudo chmod 755 /etc/init.d/gmediarenderer
$ sudo update-rc.d gmediarenderer defaults

Reboot (either “sudo shutdown -r now” or just turn it off and on again) and you should have a working system.

Installing software on the media server

I have all my CDs ripped as FLAC files along with some MP3s I’ve bought on a small linux box (an Acer Revo Aspire 3700 bought a couple of years ago in the pre-Raspberry era) with 2 USB drives plugged into it. It currently runs some version or other of Ubuntu. There’s no reason that you couldn’t use another Raspberry Pi for this with a USB disc drive attached or even the same Raspberry Pi, perhaps pointed at a NAS box for the media storage.

We need to install:

  • minidlna: this serves up the music files using the DLNA / UPnP protocol;
  • BubbleUPnP server: this provides the OpenHome protocol on top of all the UPnP devices so that all your controllers (phones, tablets) share the same playlist and “playing now” view.

For minidlna you can just use apt-get:

$ sudo apt-get install minidlna

Point minidlna at your music files by editing the /etc/minidlna.conf file, e.g.:

# set this to the directory you want scanned.
media_dir=A,/mnt/usbdisc1/music/albums

# set this if you want to customize the name that shows up on your clients
friendly_name=My DLNA Server

# set this if you would like to specify the directory where you want MiniDLNA to store its database and album art cache
db_dir=/var/cache/minidlna

I also had to “sudo chown minidlna.minidlna /var/cache/minidlna” to get it to work, but YMMV.

The BubbleUPnP server is also easy to install, just following the instructions on the web site, which for me (on Ubuntu) was just:

$ sudo add-apt-repository ppa:bubbleguuum/bubbleupnpserver
$ sudo apt-get update
$ sudo apt-get install bubbleupnpserver
$ sudo start bubbleupnp

To install BubbleUPnP on a Pi, follow the “Other Java Platforms” instructions on the BubbleUPnP server web page (e.g. download the zip file etc).

Then go to the address “http://your.media.server:58050″ and you will see the BubbleUPnP server admin interface. The important page for us is the “Media Renderers” tab where you should find the Raspberry Pi’s gmrender service listed as “Raspberry”. Select it and tick the “Create an OpenHome renderer” box on the right and that’s that sorted.

Installing software on Android devices

If you have an Android phone then go to Google Play and install BubbleUPnP. It is a UPnP renderer and control point and also works with the OpenHome protocol. In other words, it will play music (and videos and pictures) from the media server and can also tell the Pi to play music. As it uses the OpenHome system, playlists and so on are shared between all Android devices connected to the system. The app has some limitations (not too restrictive) and you can pay £3 to have it unrestricted which is well worth it whether you need to or not if you ask me.

If you don’t have an Android phone, just go and buy a second-hand one for £50, don’t bother sticking a SIM card in it and just use it as a remote control!

Once installed on the phone, run BubbleUPnP and go to the “Devices” page. You should see under “Renderers” the “Local renderer” (your phone), “Raspberry” and “Raspberry (OpenHome)”. “Raspberry” will work as the renderer but choosing that bypasses the OpenHome goodness already described. So, choose “Raspberry (OpenHome)” and under the “Libraries” select your media server. You will also see “Local Media Server” there (your phone’s files) and perhaps some other computers on your network.

Finally, go to the “Library” page, choose some music and play it: it should come out of the Hi-Fi!

Final thoughts

In this post I have concentrated on the particular steps I have taken to get a working system from my starting point. There are many possible variations on this. For instance, you could have a workable system without a dedicated media server but just using your home PC instead: BubbleUPnP Server runs on Windows as well (if you need it at all), and you could use MediaMonkey for instance on the same machine to be the UPnP server. Or you could do without the media server entirely and just stream music from your phone to the Raspberry Pi.

Finally, there is a lot more to the BubbleUPnP client and server that I couldn’t cover here and which isn’t to do with the Raspberry Pi. The client for instance can play music from Google Music. You can also set up the server so that you can access it from outside your house and by some clever configuration make it so that if you go to a friend’s house who has a DLNA renderer (lots of TVs do these days) then you can use your phone to tell your friend’s TV to play music from your server!

Please see the Raspberry Pi forum for more discussion as well as the comments below.

2013-01-08 Edit: added instructions for getting PulseAudio to start on boot and altered gmediarenderer init script to make it start after PulseAudio.

2013-01-09 Edit: added instructions to save ALSA volume between reboots.

2013-01-10 Edit: clarified how to install BubbleUPnP Server on a Raspberry Pi.

2013-01-14 Edit: added link to Raspberry Pi forum.

2013-01-19 Edit: added better ALSA instructions and linked to my other post.

  • Pingback: Getting gstreamer to work on a Raspberry Pi | Stephen C Phillips

  • Thomas Williams

    I can’t get Bubbleupnp server to install on the RPi, there does not appear to be a Wheezy distribution.

    W: Failed to fetch http://ppa.launchpad.net/bubbleguuum/bubbleupnpserver/ubuntu/di sts/wheezy/main/source/Sources 404 Not Found

    I can get as far as …/dists/ in a browser but there is no …/dists/wheezy
    Do you know a workround?
    thanks
    tom

    • scp93ch

      Hi Tom,
      I’ve not tried to install BubbleUPnP on a RPi yet (I put it on my media server which runs Ubuntu). I see that there’s a source code zip file available though so it should be possible to just use that. It’s written in Java so you’ll need the latest OpenJDK package installed. Let us know if you get anywhere – I might have time to look into it myself in the next couple of days.

      • Thomas Williams

        Sorry I am new to linux. How would one go about compiling a java app from a zipped source code? Is it a similar process to installing gmediarender from the git repository? I can’t seem to find any info on it, although I may just not have dug deep enough or not understood what I was reading.

        On a side note, I ended up changing pulse system start to 1 and running gmediarender as pulse instead of pi. Also what happens to the log files as im guessing if not removed or somehow dealt with they could get rather large judging from the amount of code i saw when I first tried this? (ran it on boot but not as daemon so it filled the window ^c didn’t work and the other windows [F2 things] didn’t present the login ended up having to learn how to ssh in order to get back in)

        thanks

        • SteveH

          I ran into the same problem as I’m running everything from the Pi, what I think I did was this:

          If you follow the BubbleUPnp link in the instructions above and then follow the instructions a bit further down under the Other Java Platforms heading. Namely:

          Install Java
          sudo apt-get install openjdk-7-jre-headless

          Download BubbleUPnp Server
          extract zip file
          cd to unzipped folder
          chmod +x launch.sh (or right click launch.sh, Permissions –> make executable)
          double click the launch.sh

          I’ve got my Pi pointed at a NAS box for the music files. Created a mount point using the following http://rasspberrypi.wordpress.com/2012/09/04/mounting-and-automounting-windows-shares-on-raspberry-pi/ and put this into the minidnla config.

          Hope that works for you!

          • Hexark

            Hey when i run add-apt-repo i get this error

            Traceback (most recent call last):

            File “/usr/bin/add-apt-repository”, line 160, in

            sp = SoftwareProperties(options=options)

            File “/usr/lib/python2.7/dist-packages/softwareproperties/SoftwareProperties.py”, line 96, in __init__

            self.reload_sourceslist()

            File “/usr/lib/python2.7/dist-packages/softwareproperties/SoftwareProperties.py”, line 584, in reload_sourceslist

            self.distro.get_sources(self.sourceslist)

            File “/usr/lib/python2.7/dist-packages/aptsources/distro.py”, line 87, in get_sources

            raise NoDistroTemplateException(“Error: could not find a ”

            aptsources.distro.NoDistroTemplateException: Error: could not find a distribution template

          • scp93ch

            The problem is that there is no pre-built package of BubbleUPnP server for the RPi so the add-apt-repository command fails. As Steve said (above) you need to follow the instructions under “Other Java Platforms” on the BubbleUPnP server web page. I’ll update my post to make this clearer.

          • http://www.facebook.com/profile.php?id=61308995 Philip King

            I have got BubbleUPnP server to run on a RasPi, by following those instructions. However, I had to install the openjdk-6-jre package first.

          • http://www.facebook.com/profile.php?id=61308995 Philip King

            And to clarify, I didn’t use the Oracle embedded Java you can download, couldn’t get that to work. But the open version seems to work fine.

  • Pingback: A UPnP renderer for the Raspberry Pi | Stephen C Phillips

  • http://twitter.com/lloydwatkin Lloyd Watkin

    Are you able to play the same file across multiple devices at the same time? Like a sonos box. For example, I’m in the home office listening to some music and decide to go and make a coffee, can I tell it to stream to home office and kitchen devices at the same time whilst I get my caffeine fill? Nice work BTW :)

    • scp93ch

      As far as I know, you can’t do this. Each device has a separate playlist.

      • http://twitter.com/thaytan Jan Schmidt

        I’ve been working on Aurena (https://github.com/thaytan/aurena), for synchronised playback. It also uses GStreamer, but doesn’t use UPnP in any way… yet.

    • Alun King

      You can use squeezeplug and the Squeezecommander remote app to do this using the squeezebox software.

  • Alun King

    I’ve got a squeezebox server (AKA Logitech Media Server) running at home for my squeezebox radio and this is UPnP compatible, which means I can run squeezebox and this on the same network, though it means I need two remotes running on my android, one for my Pi and one for my squeezebox.

    It’s also worth looking at Squeezeplug for this functionality which allows synchronisation with the squeezebox.

    • scp93ch

      As far as I know, BubbelUPnP can control a Squeezebox either directly or through the BubbleUPnP server (which gives you in the shared and persistent playlist). You should be able to use a Raspberry Pi to play music from your Squeezebox server out of your Hi-Fi with an Android remote and use the same remote to control the Squeezebox (please note, I do not have a Squeezebox, and all I’ve done is a few web searches…).

  • http://twitter.com/simontuohy simontuohy

    Hi Will this work with something like Spotify?

  • Pingback: Uporaba Raspberry Pi-ja in Android telefonov za pretok medijske vsebine preko UPnP / DLNA | Slo-Pi

  • http://www.facebook.com/henry.southgate Henyr Southgate

    Good article!

    Worth noting you can deploy a squeezebox-based network entirely for free (well, free software) using Logitech Media Server (free) and squeezeslave. This means you lose the open standardness of UPnP but has the advantage that if you have multiple players you can control them all from your Android or iOS device and sync the audio streams together for ‘Party Mode’.

    (Yeah, LMS allegedly does UPnP but I’ve had far better results with other UPnP servers :))

  • http://www.facebook.com/rob.jordan.33633 Rob Jordan

    Hi Steve – spotted this linked on the Raspberry Pi blog and got quite a surprise when I recognised your voice on the video! I’m running RaspBMC and Squeezeslave on my Pi, connected to the main lounge HiFi system. As other have noted, Squeezeslave on Android or browser works as a nice remote control driving multiple squeezeboxes. However I find the Pi is prone to audio glitches unless I stop the XBMC server.

    All the best
    Rob

    • scp93ch

      Hi Rob!

      Thanks for all the comments from people suggesting squeezebox based solutions – I’ll look into it. I found the BubbleUPnP client software to be really excellent. Along with minidlna it also gives me access to videos and photos stored on the media server. I also like the way you can have multiple clients with this solution, all synchronised and with the playlist and other state information stored on the server, but perhaps the squeezebox system also does this.

  • http://www.facebook.com/danielchamorro01 Danny Chamorro

    Good post, thanks for sharing.

  • http://www.facebook.com/craig.moore.10 Craig Moore

    This is a great tutorial – thanks very much. One question though, would I be able to use this from my server – a Wd My Book Live? Thanks.

    • scp93ch

      Well, I don’t have one myself, but looking at the specification it seems to support UPnP / DLNA. I suggest you try the Android BubbleUPnP client (for free) and check that it can connect to the WD device – you should be able to get your phone to play music from the server. If that works then try the RPi instructions to and you should then be able to play music out of the RPi. The final part, using the BubbleUPnP server to enable multiple synchronised remotes would also have to go on the RPi but from some people’s comments it sounds like that works.

      • http://www.facebook.com/craig.moore.10 Craig Moore

        That sound great – thanks very much.

  • pbat

    Great post!
    Does anybody know if minidlna supports web radio streaming? Like Henyr Southgate I’m currently using Squeezeplug on the RPi because of this ability of playing both local files and browsing / searching / playing web radio stations (almost like TuneIn).

    • scp93ch

      I don’t think minidlna can do web radio but I am no expert. There is something in the BubbleUPnP client software on Android to do with sending radio streams to a renderer using xiialive though – that could help.

      • pbat

        Yes, in fact I noticed the tab “radio” ina BubblePnP screen shot ! that’s why I’m asking. But based on my experience, web radio support is not a trivial thing. Some players can play the streams but they don’t have a “virtual tuner” i.e. they lack the ability of showing a list of web radios and searching the list (even iTunes don’t support searching across the directory, only browsing). That’s a strong point of TuneIn: they have a great directory service, complete with thumbnails etc.

        Searching “minidlna radio” gives me nothing interesting, so I guess minidlna is not the right tool but I’ll try ASAP.

        • scp93ch

          I just checked in the BubbleUPnP software: you can set it so that if you select a radio station in Xiialive (which is like TuneIn) then BubbleUPnP will kind of intercept it and instructs the renderer (e.g. RPi) to play it instead of the phone. However, this only works if the renderer can play Shoutcast streams. If it can’t then you can proxy them via the phone but that means you have to keep the phone running. I’ll check later if the RPi can deal with the stream directly.

        • scp93ch

          I just tried with Xiialive and BubbleUPnP tells the RPi to play it instead of the phone. This is the RPi playing it directly by the way, once the phone has sent the instruction you could turn the phone off if you wanted and still have the RPi continue.

          Xiialive seems decent enough – you can select radio stations by genre and search for and bookmark them. It’s not got the location radio listing that TuneIn has though.

          • pbat

            that’s exactly what I was looking for! wow, I’m impressed, glad that’s Friday, so I can go home and try :D

            thank you for helping.

  • Christopher Wilkinson

    I can’t get the gmediarenderer to start, I have followed instructions, with wired networking, and am now stuck. When the pi boots, the final line reads: [FAIL] startpar: service(s) returned failure: gmediarenderer … failed!

    Any advice? Thanks.

    • scp93ch

      Sorry to hear it’s not working for you.

      What happens if you type “sudo service gmediarender start”? That runs the start-up (“init”) script that runs at boot time. As the pi user you could also just try running “gmediarender -f Raspberry” which will run it in the foreground (not as a service) – press Ctrl-C to stop it again. Both these things should work fine, if they don’t then it won’t start on boot.

      • Christopher Wilkinson

        Running it in the foreground works (but I can’t hear anything) whereas “sudo service gmediarender start” returns the message: “gmediarender: unrecognised service”.

        Thanks for the help.

        • scp93ch

          Sorry, I should have said “sudo service gmediarenderer start” to be consistent with my other instructions.

          • http://www.facebook.com/profile.php?id=61308995 Philip King

            I am getting the “gmediarender: unrecognised service” message as a response to “sudo service gmediarenderer start” as well – any ideas how to debug what I’ve done wrong? :-)

          • scp93ch

            Check you have put the file into /etc/init.d and called it “gmedarenderer”. Check you have made it executable (with chmod +x as per the instruactions). Check you’ve told the system it is there with the “update-rc.d” command.

          • http://www.facebook.com/profile.php?id=61308995 Philip King

            I think my problem was due to the “ampersand” problem you found above – I re-copied the code and restarted and it burst into life. :-)

            I now have music streaming from a server hosted by one Raspberry Pi to another. Fantastic, many thanks for your work on this!

            My two points I found didn’t quite work for my specific setup:

            i) The wifi setup instructions didn’t work for my dongle, which is an RTL8088CUS-based Edimax device, which is popular but notoriously picky. For that I had to go into the LXDE GUI and use the wifi tool, which set it up correctly;

            ii) As I’ve mentioned below, when installing BubbleUPnP onto the Pi, I found that installing the openjava-6-jre package works well (I see someone else pointing this out below with the openjava-7-jre-headless package as well). Afterwards I continued with the installation as described.

          • http://twitter.com/smartroad78 Kelvin Shirley

            I have the same problem. When I run that script I get:

            /etc/init.d/gmediarenderer: 2: /etc/init.d/gmediarenderer: : not found
            /etc/init.d/gmediarenderer: 12: /etc/init.d/gmediarenderer: : not found
            /etc/init.d/gmediarenderer: 16: /etc/init.d/gmediarenderer: Syntax error: “&” unexpected (expecting word)

            I’ve proably done somechoolboy error! Any ideas?

          • scp93ch

            Sorry, the problem you have is that the init script in the blog post got messed up at some point and all the double quote marks were replaced with an ampersand, “quot” and a semi-colon – I’ve fixed it again now.

          • Christopher Wilkinson

            Thanks, that work well now!
            Love the setup!

          • http://twitter.com/smartroad78 Kelvin Shirley

            Yeah I noticed in the file they got changed :) Done it manually and it worked. Having to start over as my wifi wouldn’t work. Got that going now too. Love this guide!!

  • Ben Bridges

    How do i set the media server up on a windows machine. I have BubbleUPnP installed but i couldn’t find minidlna for windows and thus there is nothing in the Media Renderers Tab

  • Tom Tomis

    Cool, thanx for instructions. Will try to do the same and check it with my ArkMC on Nexus 4 and Sony TV

  • Eric Haze

    Hi Newbie here… Ideally I want to use Google Music through my Android phone and play through the RPi… I am really stuck trying to get the server setup on the Pi. I’ve unpacked the zip file (had to use a windows computer because I did not know how to do it in command) and was able to make the launch.sh executable (I think). Now when I go to run the launch.sh I get a java error? Not sure what to do…. installing Java 1.6 now in hopes that fixes it. Any suggestions on where I may have gone wrong?

    • Eric Haze

      ok I ran sh launch.sh and it seems to be running the server? …. sorry for the new questions. Really thought I would be able to handle this – once I have the server setup, how would I go about playing through my android phone?

      • scp93ch

        The BubbleUPnP server part is the icing on the cake – you should have a working system before that. Once you have gmrender installed and running you should be able to see it from the BubbleUPnP client on the phone labelled “Raspberry” and you should then be able to send your Google Music to the RPi (as long as you have the paid version of BubbleUPnP). Make sure that works first and then try the BubbleUPnP server which gives you the shared playlist etc.

        And, to unzip something in linux, type “unzip file.zip” or “unzip -l file.zip” first to see what folders and files are in the archive. (Replace “file” with the actual filename of course…)

        • Eric Haze

          Alright thanks. That clears a ton up. The issue I am having now is I cannot get the stereo jack to work. I have forced Rpi to look at the stereo vs. the HDMI (or auto) however I get no sound. I have a pair of headphones plugged in – somewhere someone mentioned you needed powered speakers – would headphones not work with the low power requirement?

          • scp93ch

            Yes, you need powered speakers – same as you need powered speakers for an iPod or similar. However, you should be able to hear the sound through the headphones.

          • Eric Haze

            Thanks for all this help – I have done everything in the article and still cannot get the audio to work/speaker to work… I have tried both MP3 and WAV files. I have set amixer cset numid=3 1 and still nothing. Tried both speakers and headphones.

            Any suggestions?

          • Eric Haze

            UPDATE 2: works! removed PulseAudio and reinstalled and sound is fantastic! Thanks for the help & tutorial!

  • dado

    Hello all,
    Just one question, has somebody try to listen music via HDMI, via AUDIO OUT (jack on RasPI) is working well, but via HDMI no music. Do I need to change something in gmrenderer or codec or some rasbian setup ?
    thanks in advance

    • scp93ch

      I haven’t tried via HDMI in this case but I did previously use the Raspbmc (www.raspbmc.com) system plugged via HDMI into my TV and that worked just fine out of the box but I don’t know what the difference was. My guess is you need to change the ALSA configuration (I’ve used the default here). I suggest you ask in the forum on the main raspberrypi web site – sorry. Most of the tricky issues come with the sound configuration, partly because it is so complicated in linux and partly because a lot of it is designed to be used from the desktop not a headless server.

  • Edward Harvey

    can a cloud computing service like dropbox be used instead of a server?

    • scp93ch

      You can put all your music in Google Music and BubbleUPnP on the phone can access it from there.

  • Petr Nosek

    I followed your instructions. Everything is running. Pulseaudio, BubbleUPnP server, gmrender, minidlna, BubbleUPnP on the Android.

    But I don’t hear music. I chose a file by BubbleUPnP on my android, I can see it in playlist, I see play button, but time of song is 0:00/3:28. Looks like paused.

    Do you have any tip, where to find error?

    • scp93ch

      Silly question: have you pressed “play”?

      You could test separate parts, e.g. in BubbleUPnP select the “local renderer” in the device list and try playing music from our server on the phone’s speaker. In the same way, you can try playing something from the phone on the RPi by changing devices in BubbleUPnP. Finally, have you heard any sound out of the RPi ever? Try “aplay /usr/share/scratch/Media/Sounds/Human/Laugh-female.wav” and see if you hear anything.

      • Petr Nosek

        :) Yes, play was pressed.

        Thank you for a tip. Problem is, that probably in pulseaudio. When I do: aplay /usr/share… I can hear nothing. Speakers are on. Pulse audio is running (checked by ps -aux | grep pulse). I’m trying to play Laugh-female.wav as a pi user (because of gconftool – as you said).

        My /etc/asound.conf:

        pi@raspberrypi ~ $ cat /etc/asound.conf
        pcm.mmap0 {
        type mmap_emul;
        slave {
        pcm “hw:0,0″;
        }
        }

        pcm.!default {
        type plug;
        slave {
        pcm mmap0;
        }
        }

        Did you configure anything else in pulseaudio? I have no experiences with pulseaudio – that’s why I follow your tutorial.

        • scp93ch

          If aplay isn’t working then I don’t think pulseaudio is the problem. Your asound.conf is the same as mine. Try typing “lsmod” to see if the audio driver kernel module is there. Mine says:

          Module Size Used by
          snd_bcm2835 12808 1

          snd_pcm 74834 1 snd_bcm2835

          snd_seq 52536 0

          snd_timer 19698 2 snd_seq,snd_pcm

          snd_seq_device 6300 1 snd_seq

          snd 52489 7 snd_seq_device,snd_timer,snd_seq,snd_pcm,snd_bcm2835

          snd_page_alloc 4951 1 snd_pcm

          • Petr Nosek

            pi@raspberrypi ~ $ lsmod
            Module Size Used by
            snd_bcm2835 13018 1
            snd_pcm 77560 1 snd_bcm2835
            snd_page_alloc 5145 1 snd_pcm
            snd_seq 53329 0
            snd_seq_device 6438 1 snd_seq
            snd_timer 19998 2 snd_pcm,snd_seq
            snd 58447 7 snd_bcm2835,snd_timer,snd_pcm,snd_seq,snd_seq_device
            dm_crypt 15047 0
            dm_mod 72801 16 dm_crypt
            evdev 9426 1
            rc_dib0700_rc5 2194 0
            leds_gpio 2235 0
            led_class 3562 1 leds_gpio
            dvb_usb_dib0700 95262 0
            dib3000mc 11896 1 dvb_usb_dib0700
            dibx000_common 8007 2 dvb_usb_dib0700,dib3000mc
            dvb_usb 17773 1 dvb_usb_dib0700
            dvb_core 97781 1 dvb_usb
            rc_core 16540 4 dvb_usb,dvb_usb_dib0700,rc_dib0700_rc5

            pi@raspberrypi ~ $ uname -a
            Linux raspberrypi 3.6.11+ #348 PREEMPT Tue Jan 1 16:33:22 GMT 2013 armv6l GNU/Linux

            Everything looks like good. I have installed XBMC and sound in xbmc is working. But my XBMC is not working with pulseaudio. When I’m testing your tutorial, my XBMC is off.

          • scp93ch

            Well, it’s beyond me I’m afraid. I notice though that you’ve got a different version of linux so your starting point was different. Sorry, but I think you’ll have to try the Raspberry Pi forums.

          • Petr Nosek

            maybe I found the problem. I remove pulseaudio (aptitude purge pulseaudio) and after that i install it again. When I do sudo alsactl store, I have this error:

            root@raspberrypi:/home/pi# alsactl store
            xcb_connection_has_error() returned true

            I’m looking for, where is the problem.

          • Mag Pi

            Looks like I have a similar problem, sound works for other things.

            The RPi shows up as a renderer, and I can hear a pop sound as I start a track, but nothing else. I will try the bits above.

            What is the base image the tutorial is based on, I can try a clean image and see if I get the same issue.

            Any chance a thread could be started on the RPi forum and linked here, so that issues can be resolved. The set-up is so good it is worth getting everything smoothed out for it. May be some pulse audio guru’s on there who can help.

            I take it will work for video and pictures too.

          • scp93ch

            The instructions are based on 2012-12-16-wheezy-raspbian.zip (it does say). I did test them step by step from a clean installation. Happy to have a thread on the RPi forum, I’ll look into it.

            The BubbleUPnP client on the phone will retrieve pictures and video from the media server fine, but personally my RPi is just headless so no point asking it to render pictures. I don’t know what gmrender does for cases other than music – probably XBMC would be better in this case.

          • Mag Pi

            Sorry I didn’t read that part a second time (it does say doesn’t it! :)). I will try reinstalling pulse-audio as suggested above, and also a clean install too.

            I shall also give XBMC another go, since it has been a while since I tried it. Audio only solution is useful anyway, it’s the first time I’ve had DLNA work well enough to come up with new renderer’s, although I’ve not tried that hard in the past (but I can see some great uses for it now).

            thanks. Meltwater (from The Mag Pi)

          • scp93ch
  • Tad Amore

    Can i stream music from Google music using this guild? or any other streaming music service?

    • scp93ch

      The BubbleUPnP client software on the phone can take music from Google Music and it will play on the RPi. It also lets you send Shoutcast streams to the RPi via the Xiialive software.

    • Guest

      Yes – run through the setup and absolutely. I have successfully played Google Music using this setup.

  • http://www.facebook.com/DiegoAlRam Diego Ramirez

    Hi people. I followed the instruction, get the server up && running, but from my adroid, when i connect nad navigate accross the folders of the server created, there are no content. Should i forget something?

    • scp93ch

      I guess this is a minidlna problem: you might check the logs for minidlna and/or restart the service. Log is /var/log/minidlna.log

      You can force a rescan of your media folders using “sudo service minidlna force-reload”. Try that and then “tail -f /var/log/minidlna.log” to see the log file as it does stuff.

      • http://www.facebook.com/DiegoAlRam Diego Ramirez

        Tks a lot. the problem was the rescan. making “sudo service minidlna force-reload” it’s finally works. Excellent tutorial!!

  • http://twitter.com/smartroad78 Kelvin Shirley

    Got it all working! Rather then having to connect to an amplifier i am building it into portable unit with its own amplifier and speaker.

    • scp93ch

      Excellent!

  • http://twitter.com/pmgadget John Howard

    Hi Steven, great article, thank you!! I finally got my first PI today and a couple of hours later I had music streaming from my Synology NAS to the stereo via the Pi. There are a couple of mods in the set up that did not require any config changes.

    1. the PI is attached to a wired network

    2. I did not set up a separate pi to stream music as the synology NAS has its own media server. This meant that I also did not have to install mini dlna and the bubble upnp server.

    music streamed first attempt – yay!

    Couple of questions:
    1 – there is a bit of a clunk when I start playing a song, this does not happen when I stream form the NAS to a computer – any idea how to stop this?
    2 – If I plug an HDMI into the the PI and a TV what changes do you think will need to be made in order to stream video?

    Excellent work many thanks!
    John

    • http://twitter.com/pmgadget John Howard

      There was one other glitch I will share just in case anyone else find the same, when running

      $ git clone https://github.com/hzeller/gmrender-resurrect.git

      the server completely hung, I just restarted the machine and started again from that point. everything else ran as expected!

    • scp93ch

      Hi John, good to hear of another success! I’m looking into the “clunk” between tracks – it’s a bit of a mystery right now. If you want to stream video then I’d suggest using XBMC (there is a ready made distribution for the Pi called Raspbmc which works just fine). It does UPnP and is designed for video.

    • gmtrash

      About the clunk see http://www.raspberrypi.org/phpBB3/viewtopic.php?f=35&t=20445 especially the posts by mahjongg and drgeoff.

      And be aware that the 1 bit DACs used to feed the RPi’s analogue audio out are only 11 bit equivalent. Not exactly Hi-Fi.

  • Peter Kilsgaard

    Hi

    First of all, super idea.

    Everything is working, but I get a cracking sound between track’s, I then added a usb (logilin UA0053) sound card, and the cracking sound is gone , but now the volume has to be at 41 i BubbleUPnP before I can hear any sound and the volume level is to high.

    Anyone have a idea/solution.

    • scp93ch

      Hi Peter, I’m glad it is working for you. I also getting a popping noise between tracks. I am looking into it but have made no progress so far (not had much time to be honest). I’m afraid I don’t know how to change the volume of your card, but you might try running alsamixer again and see if there is an additional device there.

      • Martin Norman

        Regarding the popping noise a recent firmware should have fixed some of the issues. The GPU firmware now doesn’t switch off the PWM after the device is released. You might still hear a click on the first play, but then never happens again. Info is here: https://github.com/raspberrypi/linux/issues/128 [bcm2835 ALSA sound: pop on sound playback start/completion]

        You can use https://github.com/Hexxeh/rpi-update [Hexxeh/rpi-update] to update the latest firmware, then a simple reboot and you are done.

  • Pingback: Sound configuration on Raspberry Pi with ALSA | Stephen C Phillips

  • Dave Higgins

    I had problems because I tried ‘sudo amixer numid=3 1′ and it failed

    ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Access denied

    amixer: Control default open error: Connection refused

    at the end of the install process and I couldn’t get any sound out of the 3.5mm jack. I started again from scratch and issued ‘sudo amixer cset numid=3 1′ after the upgrade step and checked using ‘sudo speaker-test’ that the sound was coming from the 3.5 mm jack. That all worked OK but I run it with about 80% volume or the sound is distorted badly.
    Thanks very much for all the info – a really nice solution.

    Dave

    • Jérome Redouté

      I get exactly the same issue… How did you fix it?
      thanks!

  • http://twitter.com/sixft2blue sixft2blue

    Hi there, and thanks for a fantastic tutorial. I have nearly completed this, but got a bit stuck when I try to load up bubbleupnp in my browser. Now, I’m a real novice here, should I just be putting in my server ip address 192.168.1.11:58050 ? because I jjust get a ‘Chrome can’t connect message’ I’ve tried other combinations too. Please help out this idiot!

    • scp93ch

      Hi, glad to hear it’s nearly working.

      Just putting the address as you wrote it into Chrome should be fine. I wonder if the service is actually running? If you are logged in to the server with bubbleupnpserver on then try the command “netstat -nle|grep 58050″: that should print a line showing that the server is “listening” on port 58050 – if not then it’s not running. Try “sudo service bubbleupnpserver status” or the same with “start” on the end. Finally, check you’ve got the right IP address with “ifconfig” and look for the “inet addr”.

      • http://twitter.com/sixft2blue sixft2blue

        Hi again. I’ve tried the netstart command, but couldn’t see anything for 58050. The “sudo service bubbleupnpserver status” command reports – “bubbleupnpserver stop/waiting”, so I did “sudo service bubbleupnpserver start” and it reported “bubbleupnpserver start/running, process 2510″ But running the Netstat command again gives the same result.

        I’m confused?

        • http://twitter.com/sixft2blue sixft2blue

          Ok, I have solved that issue, It seems I needed to install java. Done that, and I can connect now, but no sound? I’m running the output to a stereo. I’ve seen that someone else had success uninstalling & reinstalling pulse, any idiot-prrof guides on this?

          Also Minidlna isn’t seeing my music, though I guess this is just a syntax error in my conifg file?

  • HairyJamie

    Hi,
    Thanks for a great article – I now have everything up and running, using BubbleUPNP as a controller from my tablet, streaming to the Pi and out through a USB DAC to my AV Receiver.
    However – it does not seem to like 320kbps MP3s? It simply refuses to play them.
    Does anyone have this problem?
    I may have to go to a RaspBMC setup to get around this but the audio engine for USB DACs is flaky at the moment!
    Cheers.

    • scp93ch

      Hi, glad to hear it’s generally working. I haven’t tried a 320kbps MP3 but the place to look is in gstreamer. Perhaps you need another gsrteamer plugin package? Seems unlikely though.

      • HairyJamie

        Thanks for replying Stephen – I’ll take a look at gstreamer.

  • http://twitter.com/paulbarrett79 Paul Barrett

    Thanks very much for this hugely useful walkthrough! GREAT SUCCESS

  • http://twitter.com/smartroad78 Kelvin Shirley

    Technically not a program issue but was wondering if I could call on the expertise of everyone here. I am trying to power my rPi and Amp (amp is from an old USB powered computer speaker set) from the same 5V supply. However I am getting a huge amount of noise from the rPi over the power lines. Tried them with seperate power and there is no noise so it is some form of issue with the power – maybe grounding or something. Anyone have any suggestions on how I can isolate them but still have the same power supply running both?

    • RedHunters

      Great Blog so far but iI have the same problem with noise. Everything works fine but the sound is awful. There is a sound like from a drilling machine in the background and a tick sound in the same frequency than the blinking lan led. Any suggestions? thx in advance. Stefan

      • scp93ch

        Well, all I can say is that I also had terrible sound until I enabled Pulseaudio, so that’s where I’d start looking – check you’ve done all the Pulseaudio stuff.

        • http://twitter.com/smartroad78 Kelvin Shirley

          sound is fine as long as I use a separately powered amplifier/speaker, its only when i try to power both from the same supply. :-S

        • RedHunters

          Checked pulsaudio and found the config file untouched. Mea culpa. Now its working fine. Btw controlling it from iphone is possible too with the media:connect app.

  • Mikeo

    Great Tutorial. The only part i don’t get is Installing software on the media server.

    I Have a Synology NAS with MP3′s. Where do i need to install minidlna & BubbleUPnP server. On the Synology or on the Raspberry. I think i need to install it on the Synology but just to be sure.

    If i need to install MiniDLNA on the Raspberry how to give the path to my Synology NAS like /volume1/…. in minidlna.conf.

    • scp93ch

      Your Synology NAS may already serve your MP3s using DLNA. Try the BubbleUPnP Android software and see if it detects the Synology as a device (and check the NAS control panel). Minidlna is a DLNA server for the case where you don’t already have one.
      If the NAS doesn’t do DLNA then you need a DLNA server somewhere. You can install it on the NAS (if it’s possible) or on the Pi. If you put it on the Pi then you need to point minidlna at the NAS in the minidlna config file (see comment by Steve Hickman).
      Once you have DLNA running to serve your music you can stop there but you don’t get the bonus of the shared playlist etc so you might choose to install BubbleUPnP server to convert the DLNA devices into OpenHome devices. BubbleUPnP can be installed on the Pi if you want or on the NAS! Lots of choices… I put it on my media server because it’s more stable than the Pi (I’m fiddling with the Pi a lot…) and because my media server was already available through my firewall.

      • Mikeo

        Thanks for the info.

        Synology is already running BubbleUpnP and also on my HTC One X.
        Only problem is that on my Phone i can’t see the Raspberry as Renders. I can only choose my Phone or a TV when i turn it on.

  • Mikeo

    Follow up.

    When logging in on my Synology (BubbleUPnP) i can’t find my Raspberry with the tab
    Media Renderers. BubbleUPnP is working fine. I can start music en play it on my TV but there no Raspberry. So i think i need to install someting on the Raspberry. I can install MiniDNLA but i don’t find any info how to setup MiniDNLA with an external path to my NAS Mp3 collection.

    • scp93ch

      Can you play music on the Pi? Have you followed the instructions about installing gmediarenderer on the Pi? You say you can play music on the TV, but from where? That suggest you have a DLNA server running already. If you want to run minidlna on the Pi and point it at the NAS then you need to mount the NAS on the Pi. There are instructions here: http://rasspberrypi.wordpress.com/2012/09/04/mounting-and-automounting-windows-shares-on-raspberry-pi/

      • Mikeo

        Tnx for als your help. Try a lot but still no luck.

        BubbleUPnP is running on my NAS and Andoid Phone. On my Phone i can only choose my Phone or TV when it’s turned on as Render device.
        As libiray i can choose my Synology NAS so that part is running fine.

        Followed all the steps untill Installing Media Server. That part is already running.
        When i go to my Phone and start BubbleUPnP and go to devices the Raspberry don’t show up as a render. Also the raspberry don’t show up in my Bubble UPnP on my NAS with Render Devices.
        So it looks like a problem with gmediarender but while installing there where no errors and al whent fine. I now have tried it 15 time from scratch but no luck.

        • scp93ch

          Sorry to hear about your problems. The only other thing I can think of is that perhaps it is a networking issue? Are all your devices on the same Wi-Fi network?

          • Mikeo

            I seach the net and found http://chrisbaume.wordpress.com/2012/06/24/raspberry-pi-upnp-media-player/
            I followed the steps and all is running fine. Becasue i am running the Media Server on my NAS i only need to run a that part.
            I used you steps for cloning gmediarender. That one is better as a read.
            Tnx for helping.
            I still don’t know what was wrong but happy that it is working.

          • Mikeo

            I think i found the problem. the script gmediarender in init.d gives the problem that i don’t see the raspberry as a render. At the other website i found the is a other script that is not running gmediarender as user Pi.
            Then it is working but sound is horribel. On the other site a user had also that problem and changed the script so the it is running for a pi user, same as your script.
            When i use this script then i don’t see the Raspberry as a render player anymore.
            Hope you have some tips on that part.

          • scp93ch

            Okay, I don’t know why it is not working with the pi user. However, the bad audio you now have will be because the gconftool commands in the instructions were executed as the pi user so only apply to that user. If you are now running it as root for instance then you need to execute those commands as the root user.

  • RedHunters

    More than one Renderer in my network possible? Now my Pi appears as gmediarender in the devices list. Is it possible to rename it to e.g. Livingroom and therefore have a second one that is called Garden. The next step would be playing the same music in both devices or even further different music in both Pis? (Give him an inch an he will take a mile) thx Stefan

    • scp93ch

      Yes, it’s easy to set up two with different names but you cannot synchronise music between the two: they have different independent playlists. The change you need to make is in the init.d script (/etc/init.d/gmediarenderer). The line starting “start-stop-daemon” needs to change: the -f option names the device (e.g. “Garden”) and also to have 2 of them operating correctly each one needs a different UUID set. Go to e.g. http://www.guidgenerator.com and generate two UUIDs – one for each Pi. Then in the same line of the init script, after e.g. -f “Garden” add “-u” followed by one of the UUIDs. Do the same on the other Pi but using the other UUID. This then means that the system can distinguish between the two renderers.

      • RedHunters

        Tried this but it did not work. Renderer does not work anymore. “man start-stop-deamon” does not offer this option. Is it a version thing?

        • RedHunters

          Found out that the -f option works when beeing trailed by two dashes “–”. In my case it would look like this…. -S — -f “RaspberryPi Garden – u …” and it works.

          • scp93ch

            That’s correct. The init script in the blog post above has the “–”. Everything after the “–” is passed on to the software being started, everything before it is parameters for the start-stop-daemon command.

  • Jean-Christophe Liechti

    I followed your instruction but I’ve still a problem with audio quality when using RPi as media renderer: the sound is totally distorded.

    From RPi, I can aplay a wav sound, I can also mp321 a mp3 sound. This works perfectly. But when I try to play the same mp3 file from local minidnla server through my BubbleUPNP control point, the sound is distorded.

    What am I doing wrong?

    • scp93ch

      This sounds exactly like what I had before I introduced Pulseaudio. I suggest you check you followed those instructions carefully.

  • Davinder Singh

    I want to use raspberry pi as Dlna player ? how can i do it, I just
    want to stream music stored on the android phone to raspberry pi. I
    don’t this idea of making a separate media server to store music.
    I want raspberry pi to act like wifi speaker. what should i do? please any advise will help

    • scp93ch

      Just follow the Raspberry Pi part of the instructions and use BubbleUPnP app on your phone (or other similar apps) to send music from your phone to the Pi.

    • Guest

      I’ve made a image of my SD-card, when you write the image to your SD-card, it will work. With this image your Raspberry Pi will act like a network speaker.
      Link: http://www.famprinsen.com/2013-04-10-wheezy-raspbian – gmrender.rar

  • nate ross

    Hey thanks for this! Everything is working fine, no problems! Just a minor annoyance, before playback begins on every track there’s a tiny bit of noise. I’m going to test it out using my DAC as an output device tomorrow. If the noise is due to the audio out on the Pi being switched on, this should eliminate it, but I’d rather a fix than a workaround. Thoughts?

  • David Roberts

    This is brilliant! – Someone else may have already asked this, but I couldn’t see it anywhere, but is it possible to stream media in this way from a USB harddrive plugged directly into the Pi? (rather than needing to have another PC running somewhere)

    • scp93ch

      Thanks! You can do it. You would have to install minidlna on the Pi and point it at the USB drive. For all the features you could install BubbleUPnP server on the Pi as well (see the note in my instructions).

  • http://www.facebook.com/mkl001 Mitesh Lakhwani

    thank u for this great stuff i tried n everything seems to work gr8 …but some times its shows in android bubble upnp that song is playing but no audio on my speaker…i checked the speakers too but they were all fine…see if u can fix this problem…
    n for installing bubbleUPnP server on PI do i have to install java first & did it run automatically on boot or i have to set it to do so…
    please send me a tutorial how to set it to start on boot…
    thanking you
    regards
    Mitesh

  • Henner Zeller

    Thanks, I now have added a backlink to this blog-post in the gmrender-resurrect installation file: https://github.com/hzeller/gmrender-resurrect/blob/master/INSTALL.md

    Interestingly, on my wheezy installation that I installed last week when I got my Raspberry, the pulseaudio was already working out of the box, so maybe this is not necessary anymore on recent distributions ?

    Regarding the ALSA volume: it should be possible to control this from the controller app – gmrender-resurrect has these commands implemented. The BubbleUPnP app for instance has a volume control slider in the “Now Playing” tab.

    • Henner Zeller

      Also, I added a check for the math library (-lm) in the configure script. Please try again, the latest git version should not need the LIBS=-lm parameter to ./configure anymore.

    • Henner Zeller

      It might be worth mentioning the –uuid option if there are multiple renderers in the same network; some controllers might get confused with the static UUID. See https://github.com/hzeller/gmrender-resurrect/blob/master/INSTALL.md

      • scp93ch

        Good point. I mentioned it in part of this discussion thread but I need to add it to the main text.

  • http://www.facebook.com/mikko.ahola.16 Mikko Ahola

    This looks like something to try, when I get my RPI… Is it possible to use HDMI instead of 3.5 mm plug?

    • scp93ch

      Yes, certainly. The sound quality on the 3.5mm stereo output isn’t the best so if you can use HDMI then it would be preferable. The ALSA config would be different I expect but I don’t know how – plenty of others who can help on the main RPi forums though.

  • Guest

    Thanks a lot for this post, I managed to make it work, even though I had to start over a couple of times :)

    Some info I found on the popping sounds:
    “The sound output port on boards version 1.0 and 2.0 are miss-wired
    causing distortion and a DC offset which could damage certain types of
    DC-coupled amplifiers and even loudspeakers. It is recommended that you
    use the HDMI or I2S functionality. If you need to use this port, make
    sure that the equipment you use has a DC blocking capacitor. The
    specific problem is that the surge suppression network, which should
    come between the SoC and the DC blocking capacitor comes AFTER the
    capacitor, creating a rectification effect of the signal, causing a DC
    offset and distortion. The design fix is simple, move the DC blocking
    capacitor after the surge suppressing diodes and then add a 100k
    resistor (470k, or even up to 1M is fine too) to ground. A series 100
    ohm resistor just before the jack might also help suppress unwanted RF
    interference. If high quality output is required from existing boards,
    it is necessary to remove parts D12 and D13 from the back of the board.
    The three pads should be VCC, signal and GND respectively, identify each
    pad and carefully install some resistor between 10k and 100k between
    the signal and GND, making sure not to short out VCC. This is fairly
    high-end SMD re-work, I would suggest you get some training, tools and
    practice before attempting. (ed note: the writer of this comment does
    not have said skills, only knows what would have to be done).”

    We’ll have to learn how to live with it I guess… Or practice our soldering skills :)

  • Dennis Hägg

    Check out Pianobar (Pandora) Remote as well, see http://raspberrypiserver.no-ip.org/pianobar_pandora_remote_control.html

  • Jeff Parker

    Am I correct in thinking that with multiple RPi’s you can have multiple connections on your phone to play different music from te media server on different stereo systems simaltaneously.
    Excellent blog and vid keep up the good work.

    • scp93ch

      Yes, that’s correct. Each RPi can have its own playlist and you can switch between them in BubbleUPnP on the phone.

  • Дико Първанов

    So far, so good, actually works great. BUT, do you know how I can play a stream trough multiple renders? For instance in my living room, also on the kitchen and WC :D

    • scp93ch

      No, sorry. You can’t do it with this method. Have a look in the RPi forums – I expect someone’s doing it!

    • http://www.facebook.com/david.kebler David Kebler

      I am looking to do the same thing as our home has multiple room prewired in wall speakers going to a common wiring closet. Did you find any related posts at the RPi forums yet? In the setup I envision each Pi renderer needs to be able to render/play any UPnp server stream/playlist in the house, possibly simultaneously with other Pi renderers. There will be more than one server as well.

    • David Mehren

      You can use Squeezelite to synchronize players and create a multi room sytem:
      http://www.raspberrypi.org/phpBB3/viewtopic.php?f=38&t=25778

  • Matt Lindsay

    Did you ever try doing something similar with video as well as audio? Any advice for me if I give a full video implementation a go?

    • scp93ch

      Not tried video. There are solutions such as Plex and XBMC for RPi which are what most people use.

  • Pingback: Using a Raspberry Pi with Android phones for media streaming with UPnP / DLNA | Stephen C Phillips | fortschrittsbalken

  • Guest

    Is it possible to get this running on Arch Linux? The main beneift is the boot up time

    • scp93ch

      I can’t see why not, but the RPi boots in a few seconds anyway with the standard Debian Wheezy distribution. You’d also tend to leave this sort of system turned on.

  • azureatwork

    Magic, a few issues with setting up wireless. Don’t have ethernet pugged in too as I found out it didn’t allow the WIFI to be configured!! doh! Working with Skifta & XBMC or Windows Media Player in Windows no problems!

  • Maarten Prinsen

    Thanks! This works very fine. I’ve made a ‘network speaker’ of my audio installation.

    My RPi is now dedicated audio render. You can download a image of my SD-card at: http://www.famprinsen.com/2013-04-10-wheezy-raspbian-gmrender.rar

    • http://www.stoffl.info Stoffl Sowieso

      Hi, the password’s are standard? – can i use your image to post on my page? thank you

  • Pingback: Listen to your music and play video from your RaspberryPi NAS using DLNA | chirale

  • Jon Peterson

    Since gstreamer 0.10 is no longer being maintained ( http://gstreamer.freedesktop.org/news/ ), can/should the package installs be for something newer?

    • scp93ch

      Good question! GStreamer 1.0 packages are not available for Raspbian (though I understand they can be built). Right now, using 0.10 is the simplest option. Hopefully people will get 1.0 working well and easy to install and we can switch over.

  • chris mobberley

    Great tutorial! I had a couple of hiccups mainly due to not really using jar files before but everything is working perfectly now! minidlna and grenderer are excellent! I have seen a few people ask about running bubbleupnp as a background service so inspired by your init.d script I created my own for bubbleupnp.jar file http://c-mobberley.com/wordpress/index.php/2013/04/15/bubbleupnp-background-startstoprestart-init-d-script/ let me know what you think :)

  • Mike Schmalz

    Hmm. I had the gmediarender working once from the instructions in your original post, but I never got the pulseaudio stuff working. I decided to revisit today and I found this post, so I started with the latest Wheezy image. I can use aplay to play one of those wav files just fine, so I know my audio is working, but I am getting these errors when I run gmediarender from the shell and I cannot stream an MP3 like I could previously:
    —————————————-
    Registering support for ‘application/x-yuv4mpeg’

    (gmediarender:2468): GStreamer-CRITICAL **: gst_pad_new_from_template: assertion `GST_IS_PAD_TEMPLATE (templ)’ failed

    (gmediarender:2468): GStreamer-CRITICAL **: gst_pad_template_get_caps: assertion `GST_IS_PAD_TEMPLATE (templ)’ failed

    (gmediarender:2468): GStreamer-CRITICAL **: gst_pad_set_caps: assertion `GST_IS_PAD (pad)’ failed

    (gmediarender:2468): GStreamer-CRITICAL **: gst_element_add_pad: assertion `GST_IS_PAD (pad)’ failed
    Registering support for ‘application/x-gdp’
    Registering support for ‘audio/x-wav’
    Registering support for ‘video/x-matroska’
    Registering support for ‘video/webm’
    Registering support for ‘application/x-apetag’

    (gmediarender:2468): GConf-WARNING **: Client failed to connect to the D-BUS daemon:
    Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
    GConf Error: No D-BUS daemon running

    (gmediarender:2468): GConf-WARNING **: Client failed to connect to the D-BUS daemon:
    Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
    GConf Error: No D-BUS daemon running

    (gmediarender:2468): GConf-WARNING **: Client failed to connect to the D-BUS daemon:
    Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
    GConf Error: No D-BUS daemon running

    (gmediarender:2468): GConf-WARNING **: Client failed to connect to the D-BUS daemon:
    Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
    GConf Error: No D-BUS daemon running

    Registering support for ‘audio/x-bv’
    ———————————————
    This is the live output when I am sending commands to the renderer:

    ———————————————

    Ready for rendering..
    webserver_get_info:(filename=’/upnp/rendertransportSCPD.xml’,info=0xafa01570)
    webserver_get_info:(filename=’/upnp/renderconnmgrSCPD.xml’,info=0xafa01570)
    webserver_get_info:(filename=’/upnp/rendercontrolSCPD.xml’,info=0xafa01570)
    webserver_get_info:(filename=’/upnp/grender-128×128.png’,info=0xafa01570)
    event subscription request
    Subscription request
    uuid:GMediaRender-1_0-000-000-002
    urn:schemas-upnp-org:service:RenderingControl
    1 evented variables
    Subscribe to ‘LastChange’ == ‘<Event xmlns = “urn:schemas-upnp-org:metadata-1-0/AVT/”><InstanceID val=”0″>
    <Volume val=”100″/>
    <VolumeDB val=”0″/>
    </InstanceID></Event>’
    HZ: —–> push notification : TransportState = ‘STOPPED’
    output_gstreamer_set_uri: setting uri to ‘http://192.168.157.1:57645/external/audio/media/9638.mp3′
    HZ: notify all uris changed ——

    ——
    HZ: —–> push notification : TransportState = ‘PLAYING’
    HZ: —–> push notification : CurrentTransportActions = ‘PAUSE,STOP,SEEK’

    ** (gmediarender:2505): WARNING **: Command line `dbus-launch –autolaunch=57ae80824714b7b337db9bbc5115ac19 –binary-syntax –close-stderr’ exited with non-zero exit status 1: Autolaunch error: X11 initialization failed.n

    ** (gmediarender:2505): WARNING **: Command line `dbus-launch –autolaunch=57ae80824714b7b337db9bbc5115ac19 –binary-syntax –close-stderr’ exited with non-zero exit status 1: Autolaunch error: X11 initialization failed.n

    ** (gmediarender:2505): WARNING **: Command line `dbus-launch –autolaunch=57ae80824714b7b337db9bbc5115ac19 –binary-syntax –close-stderr’ exited with non-zero exit status 1: Autolaunch error: X11 initialization failed.n

    ** (gmediarender:2505): WARNING **: Command line `dbus-launch –autolaunch=57ae80824714b7b337db9bbc5115ac19 –binary-syntax –close-stderr’ exited with non-zero exit status 1: Autolaunch error: X11 initialization failed.n

    ** (gmediarender:2505): WARNING **: Command line `dbus-launch –autolaunch=57ae80824714b7b337db9bbc5115ac19 –binary-syntax –close-stderr’ exited with non-zero exit status 1: Autolaunch error: X11 initialization failed.n
    ——————————————
    Also to note: I have no idea where 192.168.157.1 would be coming from. Everything here is 192.168.1.x /24 (255.255.255.0) Maybe that’s the local media server on bubbleupnp on my phone? if so, it’s in the wrong subnet and it worked before! Any ideas?

  • disqus_zc8ifla9ib

    Thanks a lot for this great step-by-step manual.
    If it wasn’t for this tutorial, I would have wasted a lot of time (and hair).

    Now, my Raspberry PI (running Raspbian Wheezy), an old Sony speaker and a 20 bucks amplifier module are turned into what I really call a decent UPnP renderer.

    Sincerely,

    ThaGoob

    • scp93ch

      Great!

  • Alex S

    I wonder if it would be possible to add an lcd to this project with the artist name and song title?

  • tarem

    great tuto , thx , everything work great.

    to avoid unpleasant clicks and pops when track changes you can type :

    $ pacat /dev/zero &

    to force pulseaudio to play silence between track

  • mills

    Hey great project, works a charm. Currently I’m streaming music from my media server (Mezzmo) to the raspberry with bubble upnp. Thanks for the guide.

    One question is there a reason why mp3′s with a low sample rate (eg. 22khz) sound like static?

    • scp93ch

      Glad to hear it works for you, and thanks for the message.
      I don’t know why you get funny problems with the MP3s you describe. I’ve not got anything with such a low sample rate. 22kHz is half what you need to capture the full range of human hearing.

      • mills

        I think there was some confusion about the term “sample rate” I used in my above post, I think you mean Frequency.

        But anyway Just an update, it turns out that pulse audio is meant to resample music in order for the music to be played on the PI.

        Making the following changes to etc/pulse/daemon.conf the issue I had was fixed

        resample-method = trivial
        default-sample-rate = 44100

        • scp93ch

          I am glad to hear the problem is fixed but I don’t know what the problem was!

          Human hearing frequency range is approx 20 to 20000Hz (20kHz). To completely sample a sound of 20kHz the sample rate needs to be twice that, or 40kHz (see Nyquist sampling theorem). CDs are encoded at 44.1kHz for various historical reasons but basically to capture all audible sound.

          Anyway, it would be interesting to know a little more about your problem and the information you discovered about pulse audio resampling.

  • Pingback: My Holiday Project Has Arrived (Raspberry Pi) - Page 3

  • Alex

    Hi, i found this blog entry and the hint to gmrender-ressurect helped me a lot. Thanks for that! I’m not using this on rasperry but on an usual debian based box. I still have a Problem with bubbleupnpserver/OpenHome. When i choose OpenHome as Renderer on my phone it works well since i close bubbleupnp-app. When i turn it back on it can’t find the OpenHome renderer anymore. I have to restart bubbleupnpserver to use it again. Maybe you have a hint?

  • dingow

    I LOVE that there’s finally a viable solution for streaming google music throughout my house! However, this solution won’t be complete until I can do the same with Pandora. Is there a way to control Pandora playback in the same way, using phones or tablets to send Pandora to various players in the house?

  • UCas

    Hi. I followed your instructions and landed at making gmrender. If I type “make” it answers with a few steps and then it says >output.c:49:2: error: #error “No output configured. You need to ./configure –with-gstreamer”<

    Doing configure with this flag sadly doesn't help. Any idea?

    • scp93ch

      I’ve not ever had that. I reinstalled recently from scratch with the latest version of Debian Wheezy off the Raspberry Pi website and found that the instructions that came with gmrender worked perfectly. Sorry, but I can only suggest starting from scratch. Perhaps Henner Zeller can help (the guy who made gmrender-resurrect) – look him up on Google+.

    • scp93ch
  • dingow

    FYI, I installed the latest version of Wheezy, and it came without Java (which is required for the BubbleUpnp server. I used the open jre package, and that seems to have allowed me to get the server up and running. Also, ffmpeg will be needed for transcoding options:

    sudo apt-get install default-jre

    sudo apt-get install ffmpeg

  • Hasan Aslan

    Hi there. Installed Pulseaudio and gmrender on pi. It starts without error on pi but I don’t see it as a renderer on my android phone in bubbulepnp ; it only shows local renderer. Also do I really have to install a server in my phone/pc/pi etc? Can’t I just play music with bubbleupnp on android?

    • scp93ch

      Sorry, don’t know where you’ve gone wrong with the installation. You don’t have to install a server for the music you’re right. If you want, just put gmrender on the RPi and send it music from your phone.

  • SeamanX

    Hi,

    I have still the problem with the sound. The interesting fact is that after a reboot the first time I put something on the playlist over bubbleupnp it works fine – the sound is brilliant. When the playlist is processed automatically song by song all is fine. But when I interact by skipping or load another song it sounds terribly. And this goes on until the next reboot. I reinstalled all packages and read your tutorial carefully step by step. I have no idea what more I can do. Does anyone have any hints? It would be very sad if my project now would come to a standstill.
    Many thanks in advance in for every hint!
    SeamanX

  • Pingback: Playing music on a Raspberry Pi using UPnP and DLNA (revisited) | Stephen C Phillips

  • Pingback: Media Centre | Discovering Linux

  • Pingback: Using a Raspberry Pi with Android phones for media streaming with UPnP / DLNA | Sobre Software Libre y mucho mas....

  • Andy Z

    This was a great guide for a total novice when it comes to Linux. I use jRiver media center on my PC and was having trouble getting some of the version of XMBC for RPi to stream from jRiver as a DLNA renderer. I was up in running in 30 minutes with this guide.

    My one question is how to I rename the renderer? It shows up in jRiver as Raspberry. My idea is to have 4 of these running and would like to give each a unique name so my family can easily tell which is which when using my whole home audio distribution system to play music in various rooms.

    I’m sure it is a simple edit of a config file, but the where is the issue.

    thanks again for the great guide.

  • edmun

    Can I ask a simple question?

    I’ve set correctly MINIDLNA on my raspberry pi, and I have paid Bubble UPNP on my android device.

    What I’m trying to achieve is to have access to DLNA over 3G or WiFi on my android phone wherever I am located.

    On local network I don’t see any problem at all, but struggling to get from external network.

    Currently I’ve made already a port forwarding on my router:

    DLNA – ALLOW always -192.168.0.8 (1:65535) -0.0.0.0 (8200:8200)

    DLNA2 – ALLOW always – 192.168.0.8 (1:65535)0.0.0.0 (404:404)

    DLNA3 – ALLOW always – 192.168.0.8 (1:65535)0.0.0.0 (1900:1900)

    for port 8200,1900 and 404 to accept all incoming and outgoing traffic from every single WAN address to my local raspberry pi IP, but when trying to use Bubble UPNP, and set the server, it’s giving me errors.

    Of course when I am on LAN , Bubble finds the DLNA server with no problems at all.

    I’ve tried with http://myhostname:8200 and with login and password or without those informations, it’s giving me response that “The remote server could be joined but returned HTTP error code 404 (Not Found)”

    Also can’t find why http://www.yougetsignal.com/tools/open-ports/ gives me information that port 404 is closed. I suppose that no service is currently running on this port, because 8200 have an open status.
    Any ideas how to configure MINIDLNA for this 404 port ?

    • http://scphillips.com/ Stephen C Phillips

      I have this working using BubbleUPnP Server. Have you tried that?

      • edmun

        Do you mean that on Raspberry I should set another DLNA server but with using of Bubble UPNP server app ? (sorry for late reply, my e-mail ignored notification and moved it to spam folder)

  • Russell Potee

    I followed your steps and have UPnP running on my RaspberryPi. I’m using an UPnP app on my tablet. Great results. I notice a bit of a crackling sound. The crackling is not very noticeable. Any idea where that’s coming from? I don’t get crackling using a shairplay solution, but that has it’s own limitations.

    • http://scphillips.com/ Stephen C Phillips

      Thanks for the comment. Did you try the revised guide? http://blog.scphillips.com/2013/07/playing-music-on-a-raspberry-pi-using-upnp-and-dlna-revisited/

      Using these instructions to the letter does have a crackle problem but the revised instructions do not.

      • Russell Potee

        Amazing. I followed the revised instructions and there is no crackling. Thanks!

        • http://scphillips.com/ Stephen C Phillips

          Great, sorry you didn’t see them to start with.

  • scp93ch

    That’s interesting, thanks.