RaspiPlayer Rev 2.53
Raspberry Pi internet radio player with MP3 over Bluetooth. The latest revision includes internet connection indicator, and Folder Player feature.Installation:
Note; RaspiPlayer will not work with the latest RaspiOS-buster 2020/12/02. Use revision 2020-5-27 instead.
Download the full raspbian Stretch or Buster 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.
Power ON the Pi and try connecting to it with SSH. Use firstname.lastname@example.org 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.
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 jq
sudo apt-get install ffmpeg
sudo apt-get install sxiv
sudo apt-get install imagemagick
sudo git clone https://github.com/sdushantha/kunst
sudo make install
sudo apt-get install mpd mpc
git clone https://github.com/granpino/RaspiPlayer.git
sudo chmod +x *.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 playlist
Note: If you get 'No video mode large enough for 640x430', open the file player25.py and remove the FULLSCREEN as indicated below. Or change the Raspberry resolution to 640x480 and try again.
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;
The latest revision includes Folder Player feature. If you put your 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, click on the icon under the power button. The script will delete the old playlists located in /var/lib/mpd/playlist/ and create new one. You will have to run this script every time a different USB drive is used.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;
Save and exitBluetooth
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.
You will also need to edit the mpd.conf file to include the Bluetooth speaker.
Copy the speaker mac address xx:xx:xx:xx:xx:xx
To see if your speaker is connected type;
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
name "bluetooth-speaker "
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.
name "headphone "
If you want to listen to the audio jack and Bluetooth at the same time, then add a second audio output as indicated.
name "hdmi audio jack"
You must restart the mpd server after modifications.
sudo service mpd restart
To test your speaker type;
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.git
The resolution required by the script is 480x320, and the drivers should make these changes. The file config.txt should indicate your resolution at the bottom of the file.
At this point the Pi should boot to the stretch desktop and the touchscreen workingFULLSCREEN Desktop.
The RaspiPlayer script is initially set at a resolution of 640x430 and it will fill the screen. If your Raspberry is set to 720x480 or 640x480 and wish to see the panel bar the top of the screen, open the Player25.py file and at the beginning of the file change the line to read...
screen = pygame.display.set_mode(size)
#screen = pygame.display.set_mode(size, pygame.FULLSCREEN)
When you indicate FULLSCREEN, the size of the Raspberry resolution must match the player resolution. Not-FULLSCREEN 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?