An audiobook/music/sleep tunes audio player designed to run on a Raspberry Pi
MIT License
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:
scp
😊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
.
Album art is loaded from (in order of preference):
image.jpg
or image.png
in the album foldermp3
file in the album folder that contains an embedded imageSelect the audio output channel through the UI:
Scan for and pair bluetooth devices:
dev
raspi-config
and change System options > Boot / Auto Login
to Console Autologin
.copy-pi-scripts.ps1 -Server <PiName>
which will copy Resona scripts to your Pi../install-dependencies.sh
and use one of them to install the relevant dependencies./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~/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 artifactsPublishing will:
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:
disable_splash=1
to /boot/firmware/config.txt
.logo.nologo consoleblank=0 loglevel=1 quiet splash
to /boot/firmware/cmdline.txt
.fbi
with sudo apt install fbi
/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
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