HTMLMediaElement: durationchange イベント
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
durationchange
イベントは、duration
属性が更新されたときに発生します。
構文
このイベント名を addEventListener()
などのメソッドで使用するか、イベントハンドラープロパティを設定するかしてください。
js
addEventListener("durationchange", (event) => {});
ondurationchange = (event) => {};
イベント型
一般の Event
です。
例
これらの例では、HTMLMediaElement
の durationchange
イベントのイベントリスナーを追加し、そのイベントハンドラーがイベントの発生に反応したときにメッセージを投稿します。
addEventListener()
を使用する場合:
js
const video = document.querySelector("video");
video.addEventListener("durationchange", (event) => {
console.log("理由はわかりませんが、動画の再生時間が変わりました。");
});
ondurationchange
イベントハンドラープロパティを使用する場合:
js
const video = document.querySelector("video");
video.ondurationchange = (event) => {
console.log("理由はわかりませんが、動画の再生時間が変わりました。");
};
仕様書
Specification |
---|
HTML # event-media-durationchange |
HTML # handler-ondurationchange |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
durationchange event |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
関連イベント
- HTMLMediaElement
playing
イベント - HTMLMediaElement
waiting
イベント - HTMLMediaElement
seeking
イベント - HTMLMediaElement
seeked
イベント - HTMLMediaElement
ended
イベント - HTMLMediaElement
loadedmetadata
イベント - HTMLMediaElement
loadeddata
イベント - HTMLMediaElement
canplay
イベント - HTMLMediaElement
canplaythrough
イベント - HTMLMediaElement
timeupdate
イベント - HTMLMediaElement
play
イベント - HTMLMediaElement
pause
イベント - HTMLMediaElement
ratechange
イベント - HTMLMediaElement
volumechange
イベント - HTMLMediaElement
suspend
イベント - HTMLMediaElement
emptied
イベント - HTMLMediaElement
stalled
イベント