RemotePlayback.prompt()

The prompt() method of the RemotePlayback interface prompts the user to select an available remote playback device and give permission for the current media to be played using that device.

If the user gives permission, the state will be set to connecting and the user agent will connect to the device to initiate playback.

If the user chooses to instead disconnect from the device, the state will be set to disconnected and user agent will disconnect from this device.

Syntax

RemotePlayback.prompt();

Parameters

None.

Return value

A Promise that resolves with undefined after the user accepts or rejects the prompt.

Exceptions

The promise will be rejected with one of the following exceptions:

DOMException InvalidStateError
Thrown if disableRemotePlayback is true for the media element.
DOMException OperationError
Thrown if there is already an unsettled promise for this media element, or browsing context.
DOMException InvalidAccessError
Thrown if the user has not interacted with this device recently.
DOMException NotSupportedError
Thrown if the user agent knows that remote playback of this particular media is not feasible.
DOMException NotFoundError
Thrown if remote playback is unavailable.

Examples

In the following example the user is prompted to select a remote playback device to play a video.

devicesBtn.onclick = () => {
  // Request the user to select a remote playback device.
  videoElem.remote.prompt()
    // Update the UI and monitor the connected state.
    .then(updateRemotePlaybackState);
    // Otherwise, the user cancelled the selection UI or no screens were found.
};

Specifications

Specification
Remote Playback API
# dom-remoteplayback-prompt

Browser compatibility

BCD tables only load in the browser