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

Now you have to download the actual program files of the "gmrender" from the corresponding GitHub.

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.

To do this, first switch to the "gmrender-resurrect" folder - created by cloning from the GitHub - with the following command.
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

This step is about compiling and installing the "gmrender".

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 this step, you "turn up" the output volume of the RaspberryPi to the maximum level. Don't worry: The volume can be adjusted later via the "music transmitter". However, to ensure that you have the maximum available volume range, it makes sense to set the maximum volume in the RaspberryPi.

Enter the following command and...
alsamixer
...increase the volume in the "window" that opens with the "up" arrow key until you reach the maximum level.

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"
Save this by pressing "CTRL-X"...
...and confirm this with "J" and "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.

You can find an app for Android that works well in the PlayStore under "Hi-Fi Cast Music Player". There are also corresponding apps for Apple devices. Search here for apps that support DLNA or UPNP. You can now test the output on the RaspberryPi with one of these apps.

Install the app from the PlayStore.
Then start the app and select a song from your music library.
This will then first be played on your phone, which you can recognize by the text "Play on this device". Now click on this text...
...to display the menu of available playback devices. Your RaspberryPi is now displayed here as "RaspiDlna". Click on it and the music playback should start on your RaspberryPi.
You can tell that the music is now being played on the RaspberryPi by the message "Play on RaspiDlna" at the bottom of the 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.