HTMLVideoElement: Methode cancelVideoFrameCallback()

Baseline 2024
Newly available

Since October 2024, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

Die cancelVideoFrameCallback()-Methode des HTMLVideoElement-Interfaces storniert einen zuvor registrierten Video-Frame-Callback.

Syntax

js
cancelVideoFrameCallback(id)

Parameter

id

Eine Zahl, die die ID des Video-Frame-Callbacks darstellt, das Sie stornieren möchten. Dies ist der Wert, der von dem entsprechenden HTMLVideoElement.requestVideoFrameCallback-Aufruf zurückgegeben wird.

Rückgabewert

Keiner (undefined).

Beispiele

Stornieren eines Video-Frame-Callbacks

Dieses Beispiel zeigt, wie Sie cancelVideoFrameCallback() verwenden, um einen zuvor registrierten Video-Frame-Callback zu stornieren.

js
const updateCanvas = (now, metadata) => {
  // Do something with the frame

  // ...

  // Re-register the callback to run on the next frame
  // It's important to update the videoCallbackId on each iteration
  // so you can cancel the callback successfully
  videoCallbackId = video.requestVideoFrameCallback(updateCanvas);
};

// Initial registration of the callback to run on the first frame
let videoCallbackId = video.requestVideoFrameCallback(updateCanvas);

// ...

// Cancel video frame callback using the latest videoCallbackId
video.cancelVideoFrameCallback(videoCallbackId);

Spezifikationen

Specification
HTMLVideoElement.requestVideoFrameCallback()
# dom-htmlvideoelement-cancelvideoframecallback

Browser-Kompatibilität

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
cancelVideoFrameCallback

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
See implementation notes.

Siehe auch