HowTo: RaspberryPi – Music streaming to the RaspberryPi via DLNA client

Just when your RaspberryPi is lurking in StandBy most of the day, it makes sense to give him other tasks than originally planned.

This is the case, for example, with the RaspberryPi I use for my MagicMirror. This takes over in the bathroom, the display of current content for my MagicMirror. In addition to this task, he does not really have much to do. So I came to the first thought: Why not use the RaspberryPi as Internet radio? Brushing your teeth, taking a shower, etc. are definitely more fun with music.

In search of a suitable solution for the integration of an internet radio, I soon came across the possibility of extending the RaspberryPis functionality with a DLNA streaming client.

All you have to do is connect an active speaker to the RasperryPi and install and configure the appropriate software.

How to do it and what you have to pay attention to is described in the following article.

Hints for our lovely english readers: Basically, many of the articles on Nerdiy.de are translations from the original german articles. Therefore, it may happen here and there that some illustrations are not available in english and that some translations are weird/strange/full of mistakes or generally totaly wrong. So if you find some obvious (or also not obvious) mistakes don't hesitate to leave us a hint about that in the comment section. 
Also please don't get confused, that instead of a "dot" often a "comma" is used as decimal separator. 🙂


Safety instructions

I know the following hints are always a bit annoying and seem unnecessary. But unfortunately, many people who knew it "better" from carelessness lost their eyes, fingers or other things or hurt themselves. In comparison, a loss of data is almost not worth mentioning, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Even the coolest project is worth no injury or other annoyance. https://www.nerdiy.de/sicherheitshinweise/


Requirements

Helpful Articles:
To be able to install a DLNA client on your RaspberryPi’s, it should be prepared so that you can access it via SSH.

The following three articles describe what to do to prepare the RaspberryPi:
RaspberryPi – Setting up for Nerdiys!
RaspberryPi – The first configuration
RaspberryPi – Controlling the RaspberryPi via SSH

Required tools:
-none-

Required material:

In the following list you will find all the parts you need to implement this article.


Log in via SSH on the RaspberryPi

To get started, you first need to log in to RasPi with SSH on Putty. How to do it is described in the article RaspberryPi - Controlling the RaspberryPi via SSH.

After entering your username and password you can start to enter the first commands.

Update package management

The package management in Linux is a "central point" over which various software packages can be installed. For this to work reliably, the lists and sources of package management should be updated before installing any new packages.

To start the package management update you have to enter the following command.
sudo apt-get update && sudo apt-get upgrade
Depending on how long your last update of the package management is, this process can take some time. First, the lists are updated in which the individual repositories are referenced.
Then the packages themselves are updated. As this additional memory is occupied, you will again asked for your consent. You have to confirm this with a "J"(in German) or a "Y" and "Enter".
When the update is complete, you will see a small summary of the duration and scope of the update.

Install the required packages

To be able to use the DLNA client, you must first install a few packages. This is done with the following command.
sudo apt-get install libupnp-dev libgstreamer1.0-dev gstreamer1.0-libav gstreamer1.0-plugins-* -y
The installation of these packages takes about three minutes. So do not be surprised if your RaspberryPi works a bit longer.
Now you have to install a few plugins for the gstreamer package. This is done with the following command.
sudo apt-get install gstreamer0.10-plugins-* pulseaudio -y

Create folders and clone software from a GIT repository

Now you have to load the actual program files of the “gmrender” from the corresponding GitHub.

To do this, first create a folder where you copy the program files. This is done with the following command.
mkdir dlnaClient
Then you change to the just created folder with the following command…
cd dlnaClient
… and start the download from the GitHub with the following command.
git clone https://github.com/hzeller/gmrender-resurrect.git

Perform automatic configuration

In this step, you will need to run some of the included configuration scripts.

To do this, first switch to the “gmrender-resurrect” folder – created by cloning from the GitHub – with the following command.
cd gmrender-resurrect
Then you start the first configuration script.
./autogen.sh
This should be completed in a few seconds. After that you can …
… start the next configuration script.
./configure
After a few seconds, this should be completed.

Build or compile software

This step is about compiling and installing the “gmrender”.

Starts the compilation by inserting your following command.
make
Now you can start the installation.
sudo make install

Setting the audio sources

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

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

gconftool-2 -t string --set /system/gstreamer/0.10/default/musicaudiosink pulsesink

Set Alsamixer volume

In this step, you “spin” the output volume of the Raspberry Pi to the maximum level. Do not worry: the volume can be adjusted later via the “Music Channel”. So that you also have the maximum available volume range available, it makes sense to adjust the RaspberryPi to the maximum volume.

Enter the following command and …
alsamixer
… increase the volume in the opening “window” with the “up” arrow key until you reach the maximum level.

Set autostart of the software

In order for the DLNA client to start automatically the next time you start the RaspberryPi, you can enable the autostart.

Enter the following command …
sudo crontab -e
… and navigate, in the opening editor, with the arrow keys to the end of the file.
There you enter the following lines by copying and inserting them with right-click.
@reboot pulseaudio --start
@reboot /home/pi/dlnaClient/gmrender-resurrect/src/gmediarender -f "RaspiDlna"
Save this by pressing “CTRL-X” …
… and confirm this with “J” and “Enter”.
After restarting your RaspberryPi, the DLNA client should start automatically.

Take a first test

Thanks to the standardization, you can feed the installed DLNA client from different sources. One possibility is to use a smartphone with the right app.

An app for Android that works well can be found in the PlayStore under “Hi-Fi Cast Music Player”. There are also apps for Apple devices. Look for apps that support DLNA or UPNP. With one of these apps you can now test the output on the RaspberryPi.

Installs the app from the PlayStore.
Then start the app and pick a song from your music library.
This will then be played back on your phone, which you can recognize by the font “Playing on this device”(In Screenshot it is written in German “Wiedergeben auf Dieses Gerät”). Now click on this font …
… to display the menu of the available players. Here your RaspberryPi will be displayed as “RaspiDlna”. Click on it and music playback should start on your RaspberryPi.
The music is now played on the RaspberryPi, you also recognize the message “Play on RaspiDlna” at the bottom of the app.

I hope everything worked as described. If not or you have any other questions or suggestions, please let me know in the comments. Also, ideas for new projects are always welcome. 🙂

Fab

P.S. Many of these projects - especially the hardware projects - cost a lot of time and money. Of course I do this because I enjoy it, but if you appreciate it that I share these information with you, I would be happy about a small donation to the coffee box. 🙂

Buy Me a Coffee at ko-fi.com

Leave a Reply

Your email address will not be published. Required fields are marked *