<video id="videoElement" src="https://example.org/media.ext">
<button id="deviceBtn" class="hidden">Pick device</button>
</video>Remote Playback API / notebook
Remote Playback API
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
.hidden {
display: none;
}const deviceBtn = document.getElementById("deviceBtn");
const videoElem = document.getElementById("videoElement");
function availabilityCallback(available) {
// Show or hide the device picker button depending on device availability.
if (available) {
deviceBtn.classList.remove("hidden");
} else {
deviceBtn.classList.add("hidden");
}
}
videoElem.remote.watchAvailability(availabilityCallback).catch(() => {
// If the device cannot continuously watch available,
// show the button to allow the user to try to prompt for a connection.
deviceBtn.style.display = "inline";
});