Lorixen.
EN

Choosing a Speaker in a Browser App: Select the Device, Then Confirm the Audio Route

If a browser app plays recorded instructions or training audio, an output-device control should make clear which device it is trying to use and whether the change succeeded. Selecting a headset is not the same operation as assigning an audio player to that headset.

Treat this as an optional capability for explicitly supported browsers. Keep a usable ordinary playback route when custom speaker selection is unavailable. Do not promise that every browser can list and switch all connected devices.

Separate the recording from the output device

A spoken voice, an audio file and a physical speaker are different choices. This guide concerns routing an HTML media player's output to an authorised device. It does not establish how a browser's speech-synthesis service chooses its audio route, nor does it describe recording from a microphone.

An illustrative use case is a training portal where someone prefers a headset instead of the computer's speakers. The useful requirement is not simply “add a device dropdown”. It is “let the person deliberately choose an available output, apply it to the intended player and understand a failure without losing access to the lesson”. This is a proposed workflow, not a tested client implementation.

Permission to choose is not a completed switch

MDN's selectAudioOutput documentation describes a prompt allowing the person to select an output device. A successful selection grants permission to use the chosen device as an output sink and returns information about it.

MDN separately documents setSinkId as the method that assigns an audio output device to a media element. It returns a promise and only works when the application has permission to use the specified device. A switch can fail even after the interface has offered a choice.

For the brief, define separate states: selection requested, selection cancelled or unavailable, route change pending and route change confirmed. Do not show a success label solely because a device name appeared in the selector. Also do not interpret a successful API operation as proof that the user actually heard the sound: volume, the physical device and the surrounding setup still need a practical check.

Make the supported environment explicit

MDN identifies secure-context requirements for both operations. Device selection also requires transient user activation, such as interacting with a control, and can be restricted by the speaker-selection Permissions Policy. Its documentation labels the selection method experimental and directs implementers to check browser compatibility.

A requirement that works in one developer's browser therefore needs a stated support boundary. Ask which browser and operating-system combinations will be exercised. Check the real hosting and embedding arrangement, rather than assuming a feature demo proves it will work inside a different parent page.

When the feature is unavailable or policy-blocked, give an honest explanation and preserve the agreed default-output option. Requesting a microphone is not the same thing as asking the person to choose a speaker; do not add unnecessary recording permissions merely to make the interface seem more capable.

Remembering a choice needs revalidation

MDN explains that a saved device identifier must pass through selectAudioOutput successfully before it can be reused with setSinkId. The same physical device may be returned with a new identifier. A previously stored string is therefore not a permanent, universally valid hardware address.

As a project rule, treat a remembered preference as something to attempt and confirm, not as proof that the device is present and authorised today. Decide what happens when a headset is missing or access has changed. The person should be able to choose again without being trapped behind an obsolete preference.

Also decide whether the choice applies to one player or all players in the application. Assigning one media element does not, by itself, specify the route for every other sound source on the page.

Test failure without playing private content

Use a short nonconfidential sample and a supported device setup. In your acceptance plan, request an explicit selection and a confirmed route change for the intended player. Then test cancelling the prompt, a denied or restricted selection, an unavailable saved device and a failed switch where reproducible.

Ask what the app does when a device disappears during playback. Agree whether it pauses, asks for another choice or offers a clearly identified default route. Do not silently promise confidentiality because a headset was selected earlier; a routing control is not a guarantee that audio cannot be heard elsewhere.

Verify that controls work with the agreed keyboard and assistive-technology setup, and that the lesson remains accessible through its ordinary playback and text alternatives. These are proposed commissioning checks, not browser or hardware certification.

Bring the media type, supported environments and fallback rule to a web-app discussion. A useful speaker selector is an understandable route-changing workflow, not merely a list of device names.

WhatsAppLet’s talk