Skip to content

fix(web): hide cast device row when no Cast/AirPlay target is detected#14457

Closed
raymondjacobson wants to merge 1 commit into
mainfrom
claude/inspiring-northcutt-9a1c5c
Closed

fix(web): hide cast device row when no Cast/AirPlay target is detected#14457
raymondjacobson wants to merge 1 commit into
mainfrom
claude/inspiring-northcutt-9a1c5c

Conversation

@raymondjacobson

@raymondjacobson raymondjacobson commented Jun 8, 2026

Copy link
Copy Markdown
Member

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.

  • Chromium (Cast): RemotePlayback.watchAvailability() reports availability changes; cleaned up via cancelWatchAvailability().
  • Safari (AirPlay): the webkitplaybacktargetavailabilitychanged event reports available / not-available.
  • If a platform can't report availability (rejects with 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 — new available state + availability-watching effect for both Chromium and Safari paths.
  • CastButton.tsx — passes castAvailable down to the popup.
  • ConnectPopup.tsx — conditionally renders the device row on castAvailable || isCasting.

Testing

  • tsc --noEmit and eslint pass on the changed files.
  • Live browser verification wasn't practical: the cast button only renders in the play bar with an active track, and availability depends on real Cast/AirPlay hardware on the network (absent in a headless preview, where the row correctly stays hidden — the new default).

🤖 Generated with Claude Code

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>
@changeset-bot

changeset-bot Bot commented Jun 8, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 0924d7e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

🌐 Web preview ready

Preview URL: https://audius-web-preview-pr-14457.audius.workers.dev

Unique preview for this PR (deployed from this branch).
Workflow run

@raymondjacobson

Copy link
Copy Markdown
Member Author

Closing — the availability gate here relies on the W3C Remote Playback API (audio.remote.watchAvailability()), which reports no devices when the audio element is routed through Web Audio via createMediaElementSource (as this app does in AudioPlayer.ts). That makes the gate hide the cast row even when Cast devices are present, which is worse than the original behavior. Accurate detection would require integrating the Google Cast sender SDK; deferring that for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant