fix(web): hide cast device row when no Cast/AirPlay target is detected#14457
fix(web): hide cast device row when no Cast/AirPlay target is detected#14457raymondjacobson wants to merge 1 commit into
Conversation
The "Connect" popup always showed a "Google Cast devices" (or "AirPlay devices") row even when no wireless target was on the network, which is confusing — clicking it opened an empty system picker. Detect real device availability and only render that row when a target is reachable (or while already casting, so the user can still disconnect): - Chromium: RemotePlayback.watchAvailability() / cancelWatchAvailability() - Safari: the webkitplaybacktargetavailabilitychanged event If a platform can't report availability, we assume a device may be present so the cast flow is never hidden on capable browsers. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
🌐 Web preview readyPreview URL: https://audius-web-preview-pr-14457.audius.workers.dev Unique preview for this PR (deployed from this branch). |
|
Closing — the availability gate here relies on the W3C Remote Playback API ( |
Problem
The player's Connect popup always listed a Google Cast devices (or AirPlay devices) row — even when there were no wireless targets on the network. With nothing to connect to, clicking it just opened an empty system picker, which is confusing.
Fix
Detect whether a wireless playback target is actually reachable, and only render the device row when one is (or while already casting, so the user can still disconnect). The "This web browser" option always remains.
RemotePlayback.watchAvailability()reports availability changes; cleaned up viacancelWatchAvailability().webkitplaybacktargetavailabilitychangedevent reportsavailable/not-available.NotSupportedError, or the API is missing), we assume a device may be present so the cast flow is never hidden on capable browsers.The cast icon itself is unchanged — only the in-popup device row is gated.
Changes
useRemotePlayback.ts— newavailablestate + availability-watching effect for both Chromium and Safari paths.CastButton.tsx— passescastAvailabledown to the popup.ConnectPopup.tsx— conditionally renders the device row oncastAvailable || isCasting.Testing
tsc --noEmitandeslintpass on the changed files.🤖 Generated with Claude Code