HowTo: Raspberry Pi – Music streaming to the Raspberry Pi via DLNA client

Especially if your RaspberryPi spends most of the day in standby mode, it makes sense to give it tasks other than those originally intended.

This is what happened, for example, with the RaspberryPi that I use for my MagicMirror. It takes over the display of current content for my MagicMirror in the bathroom. Apart from this task, however, it doesn't actually have much to do. So the first thing I thought of was: why not use the RaspberryPi as an Internet radio? Brushing your teeth, showering and so on are definitely more fun with music.

While searching for a suitable solution for integrating an Internet radio, I soon came across the possibility of expanding the RaspberryPi with a DLNA streaming client.

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

How to do this and what you need to consider is described in the following article.


Safety instructions

I know the following notes are always kind of annoying and seem unnecessary. Unfortunately, many people who knew "better" have lost eyes, fingers or other things due to carelessness or injured themselves. Data loss is almost negligible in comparison, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Because even the coolest project is not worth injury or other trouble.
https://www.nerdiy.de/sicherheitshinweise/

Affiliate links/advertising links

The links to online shops listed here are so-called affiliate links. If you click on such an affiliate link and make a purchase via this link, Nerdiy.de will receive a commission from the relevant online shop or provider. The price does not change for you. If you make your purchases via these links, you support Nerdiy.de in being able to offer other useful projects in the future. 🙂 


Requirements

Helpful articles:
So that you can install a DLNA client on your RaspberryPi, it should of course be prepared so that you can access it via SSH.

The following three articles describe what needs to be done to prepare the RaspberryPi:
RaspberryPi – setup for nerdiys!
RaspberryPi – The first configuration!
RaspberryPi – Control the RaspberryPi via SSH

Required tool:
-no-

Required material:

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


Log in to the RaspberryPi via SSH

To start, you must first log in to the Rasp Pi with Putty via SSH. How to do this is in the article RaspberryPi - Control the RaspberryPi via SSH described.

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

Update package management

The package management in Linux is a "central place" through which various software packages can be installed. In order for this to work reliably, the lists and sources of the package management should be updated before each installation of new packages.

To start the update of the package management you have to enter the following command.
sudo apt-get update && sudo apt-get upgrade
Depending on how long ago your last update of the package management was, this process can now take a while. The lists that refer to the individual package sources are updated first.
After that, the packages themselves are updated. Since additional memory is occupied, you will be asked again for your consent. You have to confirm this with a "J" and "Enter".
Once 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 can be 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 don't be surprised if your RaspberryPi takes a little longer.
Now you need to install a few plugins for the gstreamer package. This can be done with the following command.
sudo apt-get install gstreamer0.10-plugins-* pulseaudio -y

Create folders and clone software from a GIT repository

Nun müsst Ihr die eigentlichen Programmdateien des „gmrender“ aus dem entsprechenden GitHub laden.

To do this, first create a folder into which you then copy the program files. This can be done with the following command.
mkdir dlnaClient
Then switch to the folder you have just created.
cd dlnaClient
...and start the download from GitHub with the following command.
git clone https://github.com/hzeller/gmrender-resurrect.git

Execute automatic configuration

In this step you have to execute a few of the configuration scripts provided.

Wechsel dazu zunächst mit folgendem Befehl in den – durch das clonen aus dem GitHub erstellten – Ordner „gmrender-resurrect“ mit folgendem Befehl.
cd gmrender-resurrect
Then start the first configuration script...
./autogenous.sh
This should be completed after a few seconds. After that you can...
...start the next configuration script.
./configure
This should also be completed after a few seconds.

Build or compile software

In diesem Schritt geht es darum den „gmrender“ zu kompilieren und installieren.

Start the compilation by entering the 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

Setting the Alsamixer volume

In diesem Schritt „dreht“ Ihr die Ausgabe-lautstärke des RaspberryPi’s auf die maximale Stufe. Keine Sorge: Die Lautstärke lässt sich später über den „Musik-Sender“ einstellen. Damit Ihr aber auch den maximal verfügbaren Lautstärke-Bereich zur Verfügung habt, macht es Sinn im RaspberryPi die maximale Lautstärke einzustellen.

Enter the following command and...
alsamixer
…erhöht die Lautstärke in dem sich öffnenden „Fenster“ mit der „Hoch“-Pfeiltaste bis Ihr die Maximalstufe erreicht.

Setting the autostart of the software

To ensure that the DLNA client starts automatically the next time the RaspberryPi is restarted, you can activate the autostart.

Enter the following command...
sudo crontab -e
...and use the arrow keys to navigate to the end of the file in the editor that opens.
Enter the following lines there by copying and pasting them with a right-click.
@reboot pulseaudio --start @reboot /home/pi/dlnaClient/gmrender-resurrect/src/gmediarender -f "RaspiDlna"
Speichert dies mit einem Druck auf „STRG-X“…
…und bestätigt dies mit „J“ und „Enter“.
After restarting your RaspberryPi, the DLNA client should then start automatically.

Carry out an initial test

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

Eine App für Android die gut funktioniert findet Ihr im PlayStore unter „Hi-Fi Cast Music Player“. Für Apple-Geräte gibt es ebenfalls entsprechende Apps. Sucht Hier nach Apps die DLNA bzw. UPNP ünterstützen. Mit einer dieser Apps könnt Ihr nun die Ausgabe auf dem RaspberryPi testen.

Install the app from the PlayStore.
Then start the app and select a song from your music library.
Dieses wird dann zunächst auf Eurem Telefon abgespielt, was Ihr an der Schrift „Wiedergeben auf Diesem Gerät“ erkennen könnt. Klickt nun auf diese Schrift…
…um das Menü der verfügbaren Abspielgeräte anzuzeigen. Hier wird nun Euer RaspberryPi als „RaspiDlna“ angezeigt. Klickt darauf und die Musikwiedergabe sollte auf Eurem RaspberryPi starten.
Das die Musik nun auf dem RaspberryPi wiedergegeben wird, erkennt Ihr auch an der Meldung „Wiedergeben auf RaspiDlna“ im unteren Bereich der App.

Have fun with the project

I hope everything worked as described for you. If not or you have questions or suggestions please let me know in the comments. I will then add this to the article if necessary.
Ideas for new projects are always welcome. 🙂

PS 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 think it's cool that I share the information with you, I would be happy about a small donation to the coffee fund. 🙂

Buy Me a Coffee at ko-fi.com       

Kommentar hinterlassen

Your email address will not be published. Erforderliche Felder sind mit * markiert

This site uses Akismet to reduce spam. Learn how your comment data is processed.