RaspiPlayer – Internet Radio and MP3 Folder Player Rev2.4

Internet radio with MP3 player over Bluetooth. This revision includes internet connection indicator and Folder Player.

Story

RaspiPlayer Rev 2.4

Raspberry Pi internet radio player with MP3 over Bluetooth. The latest revision includes internet connection indicator, and Folder Player feature.

Installation

Download the full raspbian Stretch orBuster image and burn to a 8GB or bigger SD card. To start you should be able to SSH to the Raspberry Pi and also use the remote connection VNC. After burning the image create an empty file called ssh in the boot folder of the SD card. Also create a file called wpa_supplicant.conf and include your WIFI credentials.

ctrl_interface=DIR=/var/run/wpa_supplicantGROUP=netdevupdate_config=1country=US  network={ssid="WiFiName"psk="password"key_mgmt=WPA-PSK}

Power ON the Pi and try connecting to it with SSH. Use [email protected] for the IP address or find the IP in your network with FING, an android App.

You do not need the LCD screen connected at this time.

After the Pi boots up, you need to turn ON the VNC server on the pi using SSH.

sudo raspi-config

Go to interfacing Options and enable VNC, then Exit.

Now connect to the Pi with VNC viewer from your computer and finish setting up your time zone and keyboard type. Use raspberrypi.local as the IP and raspberry as the password. Finish with the location and new password setup. At this time you should change the hostname from Raspberry Pi to RaspiPlayer. Go to Preferences and Raspberry Pi configuration. Now raspiplayer.local will be your IP address.

Enter the terminal screen and upgrade if needed.

sudo apt-get update sudo apt-get upgrade

After the upgrade, you are ready for the installation.

You need to install Jq and kunst for the Album-art downloads, also mpc and mpd for the player.

Also ffmpeg is needed for the Album Art.

NOTE: if you are running raspbian Buster, you do not need to install Jq, or ffmpeg.

sudo apt-get install jqsudo apt-get install ffmpegsudo apt-get install sxivsudo git clone https://github.com/sdushantha/kunstcd kunstsudo make installsudo apt-get install mpd mpccdsudo git clone https://github.com/granpino/RaspiPlayer.gitcd RaspiPlayersudo chmod +x *.sh sudo ./install.sh

Now connect some headphones or speakers to the output port to find out if Mpd is working. You must have internet access to hear the radio.

mpc load playlistmpc plaympc stopsudo ./radio.sh

At this point the RaspiPlayer should work and play internet radio only through the audio port, and without the LCD screen by using VNC viewer.

The Desktop Icon

The installation file will create a sample playlist for the internet radio. There should be an icon on the Raspberry Desktop. To open the RaspiPlayer, double tap on the radio shortcut.

To change the desktop for a single click go to file manager, click on Edit and at the very bottom select preferences. Select ‘open files with single click‘. Also check the box for ‘Don’t ask options on launch executable file’

The application uses Pygame and the touchscreen will only run under lx-terminal. If you run the application from SSH, it will not properly. I elected to run the app from the desktop because I want to run other apps on the same Pi that use the same LCD screen. I did not have to calibrate the screen to make it work.

The Playlist

I included some sample radio stations for your testing. To add other radio stations to the playlist go to http://www.radiosure.com/stations/ and copy the links. Note that not all the links will work. There are 2 ways to create a playlist.

mpc add <link of station> mpc save Radio

or edit the file at;

sudo nano /var/lib/mpd/playlists/Radio.m3u

The RaspiPlayer is set to read the MP3 files from a USB stick. Put some MP3 files in a USB stick and insert into the Pi. A playlist is created at the start of the App and stored in the database. To see if the files are there, type;

mpc listall

The latest revision includes Folder Player feature. If you put you music files in separate folders, a playlist is generated for each folder.

Playlist Generator

To generate a playlist for each subdirectory in the USB drive, run the generate-playlist.sh script. The script will delete the old playlists located in /var/lib/mpd/playlist/ and create new. You will have to run this script every time a different USB drive is used.

cd RarpiPlayersudo ./generate-playlist.sh

The Kunst App

Kunst is responsible for creating the Album art. https://github.com/sdushantha/kunst. The file is installed at /usr/bin/kunst. Kunst requires the following to operate.: sxiv, imagemagick, bash, ffmpeg, mpc, jq, and mpd. Make sure all are installed.

Kunst will download an image related to the MP3 song being played. The image is stored at /tmp folder.

The mpd.conf File

The mpd.conf file needs to show the location of the MP3 files and the type of Bluetooth speaker. Open the mpd.conf file.

sudo nano /etc/mpd.conf

And change the file location to;

music_directory                       "/mnt/usbdrive"

Save and exit

Bluetooth

It would be nice to send the music to a Bluetooth speaker. Go to the Raspberry desktop and click on the Bluetooth icon then add device. Select your Bluetooth speaker and pair. Make sure the speaker is in pairing mode. Some speakers will require a password, sometimes 0000. You will need a mouse to righ-click on the speaker icon on the menu to connect.

ou will also need to edit the mpd.conf file to include the Bluetooth speaker.

bluetoothctldevicesexit

Copy the speaker mac address xx:xx:xx:xx:xx:xx

To see if your speaker is connected type;

alsamixer

Bluealsa should be indicated and the name of your speaker.

sudo nano /etc/mpd.conf

Look for the audio output and change to include the mac address and name of the speaker. Replace the XX with your mac address

audio_output {       type            "alsa"       name            "bluetooth-speaker "       device          "bluealsa:HCI=hci0,DEV=xx:xx:xx:xx:xx:xx,PROFILE=a2d"       mixer_type      "software"}

NOTE; For Buster installation, remove the HCI=hci0 from device.

You can have more than one Bluetooth speaker, but only one will play at once. Select the desired speaker at the desktop screen.

audio_output {       type            "alsa"       name            "headphone "       device          "bluealsa:HCI=hci0,DEV=xx:xx:xx:xx:xx:xx,PROFILE=a2d"       mixer_type      "software"}

If you want to listen to the audio jack and Bluetooth at the same time, then add a second audio output as indicated.

audio_output {       type            "alsa"       name            "hdmi audio jack"}

You must restart the mpd server after modifications.

sudo service mpd restart

To test your speaker type;

mpc plaympc stop

LCD Drivers

Now install the LCD drivers provided with your screen. Most of the problems related to LCD screens are related to the drivers.

If no drivers were included, you might try LCD-show

sudo git clone https://github.com/goodtft/LCD-show.gitcd LCD-show sudo ./MPI3508-show

The resolution required by the script is 480×320, and the drivers should make these changes. The file config.txt should indicate your resolution at the bottom of the file.

nano /boot/config.txt

At this point the Pi should boot to the stretch desktop and the touchscreen working

FULLSCREEN Desktop

The RaspiPlayer script is initially set at a resolution of 480×320 and it will fill the screen. If you wish to see the panel bar the top of the screen, open the Player480.py file and at the bottom of the file edit the line.

screen = pygame.display.set_mode(size) #,pygame.FULLSCREEN)

This might be needed during troubleshooting and making changes.

Troubleshooting

If the radio fails to start, check the mpd.conf file for errors. To see if the mpd is running open the terminal and type:

sudo service mpd status

If it does not say it is running then you have a problem. Look at your mpd.conf for typing errors and correct. To restart mpd after making changes type;

sudo service mpd restart

And check again and see if it is running.

The kunst app starts at boot and if you wish to disable it enter;

sudo  update-rc.d kunst-run.sh remove

Also, did you try a Reboot?

Telephone Control

If you wish to control the RaspiRadio from your phone, there are several MPD apps available for android and Iphone. The one I use is MPD remote. From the app enter the IP address of your Pi and port 6600 and have fun…

Source: RaspiPlayer – Internet Radio and MP3 Folder Player Rev2.4

Scroll to Top