An audiobook/music/sleep tunes audio player designed to run on a Raspberry Pi.
I wanted to have a single-use device for playing audio that my kids could safely use in their bedroom, without giving them a phone or tablet that also gave them other unhelpful distractions.
This is a rebuild of an old project which had an ASP.NET core backend with a Blazor client. This new version relies on Avalonia UI. Having all the logic and UI combined in a single executable has proven to be much more efficient and development has been much quicker. This all came together as a spare time project over the course of a couple of weeks.
You can clone and run this repo locally to try it out, and deploy it to a Raspberry Pi using the dev notes below. I might look to streamline the installation process at some point if there's demand for it - I'd also be happy to receive contributions.
I've a couple of things I still want to do:
Expose a web application from the device that parents can use to upload new content, rather than usingIn progress - see the experimental web host section belowscp
😊Allow for more configuration options to allow kids to personalize things a bit, including the main icons for the home screen.Can be done using the web interface 😊
- Audiobooks
- Music
- Sleep Tunes
Files are added to the database by scanning a folder on the local filesystem. This is currently the well known location, home/pi/audiobooks
, home/pi/music
and home/pi/sleep
.
- Sleep timer to stop playback after a set time
- Auto-shutdown on lack of interactivity (2 hours by default)
- Screen dimming to prevent glare at night (30 seconds by default)
Album art is loaded from (in order of preference):
image.jpg
orimage.png
in the album folder- The first
mp3
file in the album folder that contains an embedded image
- Resona keeps track of the last played position of albums and will be ready to continue playing from the last played track when it restarts
- Scrubbing supported
- Volume control through the player in case your display doesn't have volume controls
Select the audio output channel through the UI:
Scan for and pair bluetooth devices:
- Install Raspberry Pi OS Lite. The easiest way to do this is with the Raspberry Pi Imager, making sure you apply these settings before installing:
- Set the host name to something unique on your network, e.g.
dev
- Enable SSH
- Configure the wireless LAN
- Install any dependencies for the touchscreen display attached to your Pi.
- Use
raspi-config
and changeSystem options > Boot / Auto Login
toConsole Autologin
. - From your dev computer run
copy-pi-scripts.ps1 -Server <PiName>
which will copy Resona scripts to your Pi. - From your Pi (SSH or direct), run
./install-dependencies.sh
and use one of them to install the relevant dependencies - (Optional) From your Pi, run
./configure-auto-run.sh
to configure Resona to auto run whenever your Pi starts up. If you don't do this you'll have to manually start Resona each time from either your dev computer using SSH or the Pi itself by running~/bin/Resona --drm
. You can temporarily disable the service using./disable-auto-run.sh
and re-enable with./reenable-auto-run.sh
.
Run publish.ps1 -Server <PiName>
to build and deploy the project to your Pi.
publish.ps1
options:
-Server
- The name of the Pi to deploy to-DebugBuild
Builds in debug mode with no trimming-NoClean
Only makes sense when used when publishing with -DebugBuild. Only copies changes to the Resona assemblies, keeping the existing .NET framework and other dependencies. Can be used for a faster dev inner loop when testing code on the Pi.-NoBuild
Deploys without rebuilding the packaged artifacts
Publishing will:
- Rebuild the project
- Stop and disable the service on the Pi (which will kill the app if it's running via the service)
- Copy the updated artifacts
- Re-enable and start the service on the Pi (if installed) - the app will auto run ready for you to play with it.
Some work has been done to expose a React-based web interface from the Pi. It's turned off by default but can be enabled from the advanced settings page.
Once enabled, you can access the web interface from any device on the same network as the Pi by navigating to http://<PiName>:8080
.
The web interface allows you to view what's currently in the library:
And also upload new content:
If you want to add a splash screen and get rid of all the scrolling boot up text the Pi shows, follow these steps:
- Add the line
disable_splash=1
to/boot/firmware/config.txt
. - Add
logo.nologo consoleblank=0 loglevel=1 quiet splash
to/boot/firmware/cmdline.txt
. - Add a splashscreen
- Install
fbi
withsudo apt install fbi
- Create a splash screen image and save it as
/home/pi/splash.png
sudo nano /etc/systemd/system/splashscreen.service
and enter[Unit] Description=Splash screen After=local-fs.target [Service] ExecStart=/usr/bin/fbi -d /dev/fb0 --noverbose -a /home/pi/splash.png StandardInput=tty StandardOutput=tty [Install] WantedBy=sysinit.target
sudo systemctl enable splashscreen.service
- Install
This section contains notes about the various touchscreens used during development.
Add this to the end of /boot/firmware/config.txt:
hdmi_force_edid_audio=1
max_usb_current=1
hdmi_force_hotplug=1
config_hdmi_boost=7
hdmi_group=2
hdmi_mode=87
hdmi_drive=2
display_rotate=0
hdmi_cvt 1024 600 60 6 0 0 0
Enable fkms to fix audio issues:
sudo sed -i 's/dtoverlay=vc4-kms-v3d/dtoverlay=vc4-fkms-v3d/g' /boot/firmware/config.txt
Work on the core database structure is ongoing, so I'm just going to recreate the initial database structure every time I make a change using:
cd src\Resona.Persistence
rm -r Migrations
md Migrations
dotnet ef migrations add InitialCreate --startup-project ..\Resona.UI -o Migrations