files/en-us/web/api/remoteplayback/prompt/index.md
{{APIRef("Remote Playback API")}}
The prompt() method of the {{domxref("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 {{domxref("RemotePlayback.state","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 {{domxref("RemotePlayback.state","state")}} will be set to disconnected and user agent will disconnect from this device.
prompt()
None.
A {{jsxref("Promise")}} that resolves with undefined after the user accepts or rejects the prompt.
The promise will be rejected with one of the following exceptions:
InvalidStateError {{domxref("DOMException")}}
true for the media element.OperationError {{domxref("DOMException")}}
prompt() for this media element, or browsing context.InvalidAccessError {{domxref("DOMException")}}
NotSupportedError {{domxref("DOMException")}}
NotFoundError {{domxref("DOMException")}}
NotAllowedError {{domxref("DOMException")}}
Transient user activation is required. The user has to interact with the page or a UI element in order for this feature to work.
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}}
{{Compat}}