A beautiful web radio for a living room music system
Operation
After configuring the stations, restart the service by typing,
sudo systemctl restart pi-webradio.service
then navigate to the address http://<Host>:8026/ in the browser. If the browser runs on the same system as the service, replace <Host> with localhost; otherwise, enter the IP address or name of the corresponding Raspberry Pi.
Operating the web radio is largely self-explanatory. On the left side, icons let you toggle the time, player, station selection, file selection, and tools views (see Figure 9). The Tools page is where you can stop the application, reboot, or shutdown the system. The File selection lets you play MP3 files.
The application can also record broadcasts on the fly if you press the Record button (far right in the buttonbar below the station logo). The recording will then run as long as you specified in /etc/pi-webradio.conf
. In addition to spontaneous recordings, web radio also supports scheduled recordings, even independent of the Pi web radio service. To do this, install the at package and schedule the recording with a one-liner:
# echo /usr/local/bin/pi-webradio.py -r 4 120 | at 20:00 31.10.2021
The command records channel 4 for 120 minutes. The at
daemon takes care of starting on time. The atq
command will show you the recording queue, and atrm <number>
lets you delete jobs. You might want to define regular recordings in the crontab or as systemd timers if you prefer a more modern approach.
Challenges
An integrated solution with a server and browser on one system (Figure 7) poses a few additional challenges. First, is the issue of starting the browser as an application (i.e., without the usual frames, menus, and buttons of a normal web browser). Also, you want the program to launch in kiosk mode, which prevents the user from exiting; for example:
$ chromium-browser --app=http://localhost:8026/ --kiosk
To run the browser at boot time, copy the desktop file from Listing 2 to the $HOME/.config/autostart/
directory. The name does not matter, but the file needs the .desktop
extension. The call to the browser is scripted in line 4; the script also terminates the browser later when you stop the radio server from the Tools page.
Listing 2
Desktop Autostart File
01 [Desktop Entry] 02 Name=Pi-Webradio 03 Comment=Webclient (Chrome) for Pi-Webradio 04 Exec=/usr/local/bin/webradio_chrome.sh 05 Terminal=false 06 Type=Application 07 StartupNotify=false 08 X-GNOME-Autostart-enabled=true
Another challenge is to hide the mouse cursor. To do this, you need the unclutter package, which takes care of the appropriate call in the startup script. The script also disables any power-saving options that would cause the screen to switch off.
Alternative Hardware
Not every piece of hardware in the Raspberry Pi universe is suitable for a web browser, which is why the Pi web server also provides a simple web API for control. The program webradio_cli.py
allows complete control from the keyboard – or remotely, if desired.
The project also provides a minimalist control program for Pimoroni's Pirate Audio HATs with four buttons and a miniscreen (Figure 12). The HATs are available in different versions, among others with mono speaker or with headphone output. All variants come with a 240x240px screen and four buttons.
Again, the server and the client run on the same hardware. The client monitors the four buttons and uses them to change the station and volume. The display shows the logo of the current station. If you change the station from the web interface (e.g., from a smartphone), the client also notices this and updates the image.
The program for the Pirate HAT is a good starting point for DIY projects with other hardware, such as classic 4x20cm LCDs. More info can be found in my project repository [8].
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Canonical Bumps LTS Support to 12 years
If you're worried that your Ubuntu LTS release won't be supported long enough to last, Canonical has a surprise for you in the form of 12 years of security coverage.
-
Fedora 40 Beta Released Soon
With the official release of Fedora 40 coming in April, it's almost time to download the beta and see what's new.
-
New Pentesting Distribution to Compete with Kali Linux
SnoopGod is now available for your testing needs
-
Juno Computers Launches Another Linux Laptop
If you're looking for a powerhouse laptop that runs Ubuntu, the Juno Computers Neptune 17 v6 should be on your radar.
-
ZorinOS 17.1 Released, Includes Improved Windows App Support
If you need or desire to run Windows applications on Linux, there's one distribution intent on making that easier for you and its new release further improves that feature.
-
Linux Market Share Surpasses 4% for the First Time
Look out Windows and macOS, Linux is on the rise and has even topped ChromeOS to become the fourth most widely used OS around the globe.
-
KDE’s Plasma 6 Officially Available
KDE’s Plasma 6.0 "Megarelease" has happened, and it's brimming with new features, polish, and performance.
-
Latest Version of Tails Unleashed
Tails 6.0 is based on Debian 12 and includes GNOME 43.
-
KDE Announces New Slimbook V with Plenty of Power and KDE’s Plasma 6
If you're a fan of KDE Plasma, you'll be thrilled to hear they've announced a new Slimbook with an AMD CPU and the latest version of KDE Plasma desktop.
-
Monthly Sponsorship Includes Early Access to elementary OS 8
If you want to get a glimpse of what's in the pipeline for elementary OS 8, just set up a monthly sponsorship to help fund its continued existence.