RemotePlayback: cancelWatchAvailability() 方法
RemotePlayback 介面的 cancelWatchAvailability() 方法取消了監視一個或所有可用裝置的請求。
語法
js
cancelWatchAvailability()
cancelWatchAvailability(id)
引數
id可選-
特定遠端播放裝置的
callbackId。如果傳入特定裝置的
callbackId,則該裝置將從受監視裝置列表中移除。否則,整個列表將被清除。
返回值
一個 Promise,解析為 undefined。
異常
InvalidStateErrorDOMException-
如果媒體元素的
disableRemotePlayback為true,則丟擲此異常。 NotFoundErrorDOMException-
如果傳入了
id但它不匹配任何可用的callbackId,則丟擲此異常。
示例
一旦識別並連線了遠端播放裝置,可以使用 cancelWatchAvailability() 停止監視可用裝置。
js
function switchToRemoteUI() {
// Indicate that the state is 'connecting' or 'connected' to the user.
// For example, hide the video element as only controls are needed.
videoElem.style.display = "none";
// Stop monitoring the availability of remote playback devices.
videoElem.remote.cancelWatchAvailability();
}
規範
| 規範 |
|---|
| Remote Playback API # dom-remoteplayback-cancelwatchavailability |
瀏覽器相容性
載入中…