Pre-requirements:
Raspberry Pi 3 or 4 with a sound out connector
Music for the endless loop. I recommend reviewing the music of Ross Bugden on YouTube to find the song that you want to use.
USB flash drive - copy the music to it
Blank microsd for the operating system
Install "Bullseye" or "Buster" using the Raspberry PI imager - install a minimal image onto your blank microsd.
Specify the following recommended details as part of the image customization:
hostname: musicplayer
userid: musicadm
password: use a good one! (more than 8 letters, numbers, capitals, and special characters0
Configure wireless SSID
Configure US for wireless country
Set to US locale
After the installation completes, connect it to a newtork, login, and execute the following commands:
sudo apt update
sudo apt autoremove
sudo apt upgrade
sudo apt install vlc
mkdir music
Insert the usb flash drive with the music file:
sudo mount /dev/sda1 /mnt
cp /mnt/* music
6. nano musicplayer.sh - the script is below.
#!/bin/sh
# set here the path to the directory containing your music
MUSICPATH="/home/musicadm/music"
# you can normally leave this alone
SERVICE="vlc"
# now for our infinite loop!
while true; do
if ps ax | grep -v grep | grep $SERVICE > /dev/null
then
sleep 1;
else
for entry in $MUSICPATH/*
do
ls $entry
#cvlc "$entry" -I dummy vlc://quit > /dev/null
#ls $entry
done
fi
done
7. chmod +x musicplayer.sh
8. Run the script to verify the files all list correctly. Afterwards remove the ls line and uncomment the cvlc line.
9. sudo nano /etc/rc.local
10. Above exit 0 add the following command:
/home/musicadm/musicplayer.sh &
11. sudo shutdown -r now
Test that it works if it does and you want to harden it:
sudo raspi-config
Disable SSH
Disable ethernet adapter