Skip to content

RFC: feat: pluggable audio backends + macOS backend + airplay - #431

Open
btaylor wants to merge 3 commits into
victoralvesf:developmentfrom
btaylor:feature/audio-backend
Open

RFC: feat: pluggable audio backends + macOS backend + airplay#431
btaylor wants to merge 3 commits into
victoralvesf:developmentfrom
btaylor:feature/audio-backend

Conversation

@btaylor

@btaylor btaylor commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

The Audio element in HTML is a nice, simple way to play music. However, in Electron (via Chromium), there's no way to support Airplay output on macOS. And I'd love to have aonsoku control my airplay speakers.

This is kind of a complex PR, and this level of change might not be acceptable, so I've marked this as an RFC. Would love feedback.

The patches implement a pluggable AudioBackend abstraction, as well as a macOS backend targeting AVPlayer, and an Airplay button that allows to select the output speaker(s).

Tested on macOS 26 over the last two days and seems rock solid.

btaylor added 3 commits July 1, 2026 12:01
Replace the single shared <audio> element in player.tsx with a typed
AudioBackend interface backed by HTMLAudioBackend (HTMLAudioElement +
Web Audio API). AudioBackendProvider manages three dedicated backends
(song, radio, podcast) and owns all playback logic — load, play/pause,
ReplayGain, loop, playback rate. Consumer components access backends via
useActiveAudioBackend() / useAudioBackend() hooks.

Also fixes two Chromium-specific bugs: calling pause() on a NETWORK_EMPTY
element triggers an unexpected error event, and React Strict Mode's
cleanup cycle was firing the radio error toast through listeners that
hadn't been detached before destroy() reset the audio element. The latter
is fixed by using AbortController to remove all listeners as the first
step of destroy().

This lays the groundwork for a future AVPlayerBackend on macOS.
@vercel

vercel Bot commented Jul 1, 2026

Copy link
Copy Markdown

@btaylor is attempting to deploy a commit to the Victor Alves' projects Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Jul 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
aonsoku Ready Ready Preview, Comment Jul 2, 2026 12:55pm

@victoralvesf

victoralvesf commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Thanks for the PR @btaylor.

Tested locally and I have some questions:

  1. Does the server URL need to be publicly available for AirPlay to work?

I tested it using my local server and selected my Apple TV in the AirPlay selector, but my TV couldn't play the song.

  1. Does the AVPlayer support Replay Gain?

I noticed that enabling Replay Gain doesn't affect the audio volume.

  1. Have you tested any radio stations with it?

I tried to play a few stations; they start playing, but they stop at the next audio chunk.

Other than that, I tested the HTML Audio Backend and it still works correctly (just got a few error toasts when playing a radio station).

Also, I think the audio backend should be selectable by the user, with the default always being HTML Audio, but leaving options for the user to choose (I'm already keeping it that way so other audio backends can be plugged in later). My suggestion is to add a dropdown in the Settings > Player & Audio section, so the user can pick which Audio Backend they want.

@victoralvesf
victoralvesf deleted the branch victoralvesf:development July 14, 2026 12:20
@victoralvesf victoralvesf reopened this Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants