Movatterモバイル変換


[0]ホーム

URL:


  1. 開発者向けのウェブ技術
  2. Web API
  3. HTMLMediaElement
  4. progress

このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docsコミュニティーについてもっと知り、仲間になるにはこちらから。

View in EnglishAlways switch to English

HTMLMediaElement: progress イベント

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.

progress イベントは、ブラウザーがリソースを読み込むときに定期的に発生します。

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

構文

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

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

イベント型

一般的なEvent です。

ライブデモ

HTML

html
<div>  <button type="button">Load video</button>  <video controls width="250"></video>  <div>    <label for="eventLog">Event log:</label>    <textarea readonly></textarea>  </div></div>
.event-log-contents {  width: 18rem;  height: 5rem;  border: 1px solid black;  margin: 0.2rem;  padding: 0.2rem;}.example {  display: grid;  grid-template-areas:    "button log"    "video  log";}button {  grid-area: button;  width: 10rem;  margin: 0.5rem 0;}video {  grid-area: video;}.event-log {  grid-area: log;}.event-log > label {  display: block;}

JavaScript

js
const loadVideo = document.querySelector("button");const video = document.querySelector("video");const eventLog = document.querySelector(".event-log-contents");let source = null;function handleEvent(event) {  eventLog.textContent += `${event.type}\n`;}video.addEventListener("loadstart", handleEvent);video.addEventListener("progress", handleEvent);video.addEventListener("canplay", handleEvent);video.addEventListener("canplaythrough", handleEvent);loadVideo.addEventListener("click", () => {  if (source) {    document.location.reload();  } else {    loadVideo.textContent = "Reset example";    source = document.createElement("source");    source.setAttribute(      "src",      "https://mdn.github.io/learning-area/html/multimedia-and-embedding/video-and-audio-content/rabbit320.mp4",    );    source.setAttribute("type", "video/mp4");    video.appendChild(source);  }});

結果

仕様書

Specification
HTML
# event-media-progress
HTML
# handler-onprogress

ブラウザーの互換性

関連情報

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp