HTMLMediaElement: pause イベント

pause イベントは、動作の一時停止のリクエストが処理され、動作が一時状態に入ったときに送信されるものであり、メディアが要素の pause() の呼び出しを通して一時停止した後が最も一般的です。

イベントは pause() メソッドから戻り、メディア要素の paused プロパティが true に変化した後で一度送信されます。

このイベントはキャンセル不可で、バブリングしません。

構文

このイベントを addEventListener() などのメソッドで使用するか、イベントハンドラープロパティを設定するかしてください。

js
addEventListener("pause", (event) => {});

onpause = (event) => {};

イベント型

一般的な Event です。

これらの例は、 HTMLMediaElement の pause イベントにイベントリスナーを追加してから、イベントが発生したことでイベントハンドラーが動作したときにメッセージをポストします。

addEventListener() を使用した例:

js
const video = document.querySelector("video");

video.addEventListener("pause", (event) => {
  console.log(
    "The Boolean paused property is now true. Either the " +
      "pause() method was called or the autoplay attribute was toggled.",
  );
});

onpause イベントハンドラープロパティを使用した例:

js
const video = document.querySelector("video");

video.onpause = (event) => {
  console.log(
    "The Boolean paused property is now true. Either the " +
      "pause() method was called or the autoplay attribute was toggled.",
  );
};

仕様書

Specification
HTML Standard
# event-media-pause
HTML Standard
# handler-onpause

ブラウザーの互換性

BCD tables only load in the browser

関連イベント

関連情報