RFC: feat: pluggable audio backends + macOS backend + airplay - #431
RFC: feat: pluggable audio backends + macOS backend + airplay#431btaylor wants to merge 3 commits into
Conversation
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.
|
@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. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Thanks for the PR @btaylor. Tested locally and I have some questions:
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 |
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.