This is a Raspberry Pi. A small, powerful, low cost computer.
I’m writing this blog post from the pi you see in the photo. It is very slow compared to my laptop but it works and is in front of me now, whereas my laptop is a whole 2 meters away on another desk.
This is the Raspberry Pi Model 3 B+ that used to run the background music for my small business, a shop that sells furniture and appliances for kitchens, bedrooms and bathrooms. I retired this pi from service a few years ago when we moved to a different background music service. Before the new company I used Jamendo which allowed me to licence and download a few hundred tracks every few months. I would copy them to the pi over the wifi network and the pi would play the music. I wrote a small script that meant as the pi powered on it would start playing music tracks randomly from the selection I had uploaded to it. No human interaction, once setup it ran and ran and ran. Perfect.
This year, as many years before, I have volunteered to help Santa travel around Canterbury with the Rotary Club I’m a member of. We had problems this year with the float background music in that the old donated Ipod ran out of power. When connected to a battery the plug frequently dislodged the audio connection and affected the sound quality. I realised I could repurpose my old Pi to make a better sound source for the float.
Steps
- A fresh installation of Raspbian
- Find some example code on the internet for auto-starting applications when the pi is powered.
- Find some suitable music tracks (search, find, repeat)
- Put them in a directory on the desktop called ‘music’
- Write a script to autostart the playing of music.
- Remember to select the correct audio output (3.5mm AV Jack, not the HDMIdisplay)
- Buy a suitable enclosure to secure the pi against weather. The only connections it needs when setup to run is power (through micro-usb) and the 3.5mm aduio jack out to the float speakers. I found a nice circular panel mount connector for those, easy to drill and fit.
The Script
Modifying a code idea from StackOverflow;
create a file: nano ~/.config/autostart/mygui.desktop
Add the following and save.
[Desktop Entry]
Name=AutoPlayMusic
Exec=/usr/bin/vlc -LZ "/home/pi/Desktop/music"
Type=Application
Hidden=False
Exec starts VLC, the music player application.
-LZ flags set “Loop” and “Random”, it plays forever in random order.
“/home/pi/Desktop/music” is where I put the Directory full of music files.
Restart the pi to check it works.
In the future anyone can connect a keyboard, mouse end monitor and change the music, although they will have to remove it from the case to access the USB ports.
The finished raspberry pi auto playing juke box in it’s weatherproof case.
Leave a Reply