← All projects
MA Companion
An Android and Android Auto app for my self-hosted Music Assistant server. It browses and plays my music library anywhere, and turns the phone itself into a speaker.
Music Assistant is a self-hosted music server that runs alongside Home Assistant. It organizes a music library and plays it on speakers around the house. MA Companion is an Android app I built for it, so I can use my library on my phone and in the car the same way I do at home.
What it does
- Browse the whole library: artists, albums, tracks and playlists, with search, Play All and Shuffle.
- Use the phone as a speaker: the app registers the phone as a Music Assistant player and streams audio to it, so music from the server plays on the phone, from anywhere.
- Control any player: switch between the phone and the speakers at home, and pick a default player.
- Now Playing: album art, the queue, seeking, shuffle and repeat, favorites, and saving the current song to a new or existing playlist.
- Synced lyrics that highlight and scroll along with the song, plus an “About the artist” section.
- What’s new: when new artists or albums show up in the library, the home screen shows them in a pop-up.
Android Auto
The app works on the car’s screen through Android Auto:
- Browse artists, albums and playlists, or search, from the car’s display.
- Voice commands: “play” an artist, album or playlist, or say “add to” or “save to” a playlist to save the current song.
- The current line of the lyrics shows on the car’s Now Playing screen.
- Playback keeps going through weak signal and handoffs between Wi-Fi and mobile data.
How it works
- Remote access without a VPN: the app connects through Music Assistant’s remote access, which uses WebRTC. A signaling server sets up an encrypted connection to the server at home, peer-to-peer when possible and relayed when not, so there’s no port forwarding or VPN. On the home network it can also connect directly over a WebSocket.
- Easy setup: sign in once, or scan the server’s remote ID as a QR code with the camera.
- Streaming audio: the phone speaks Sendspin, Music Assistant’s streaming protocol, over a WebRTC data channel. It syncs its clock with the server, decodes the Opus audio stream and plays it.
- Self-healing playback: the app watches for audio that stops arriving, or that arrives but doesn’t play, and reconnects on its own. This matters most in the car.
Tech
- Kotlin and Jetpack Compose (Material 3)
- Android Auto media browser service, with Media3 sessions
- WebRTC and WebSockets (OkHttp)
- Opus audio decoding (Concentus)
- CameraX and ML Kit for QR code scanning
- Coroutines, DataStore and Coil