--- title: 'HTMLMediaElement: progress イベント' slug: Web/API/HTMLMediaElement/progress_event tags: - API - Event - HTMLMediaElement - Reference - Web - progress - イベント translation_of: Web/API/HTMLMediaElement/progress_event ---
progress
イベントは、ブラウザーがリソースを読み込むときに定期的に発生します。
バブリング | なし |
---|---|
キャンセル可能 | いいえ |
インターフェイス | {{domxref("Event")}} |
イベントハンドラープロパティ | onprogress |
<div class="example"> <button type="button">Load video</button> <video controls width="250"></video> <div class="event-log"> <label>Event log:</label> <textarea readonly class="event-log-contents"></textarea> </div> </div>
.event-log-contents { width: 18rem; height: 5rem; border: 1px solid black; margin: .2rem; padding: .2rem; } .example { display: grid; grid-template-areas: "button log" "video log"; } button { grid-area: button; width: 10rem; margin: .5rem 0; } video { grid-area: video; } .event-log { grid-area: log; } .event-log>label { display: block; }
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 = 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://interactive-examples.mdn.mozilla.net/media/examples/flower.webm'); source.setAttribute('type', 'video/webm'); video.appendChild(source); } });
{{ EmbedLiveSample('Live_example', '100%', '200px') }}
仕様書 | 状態 |
---|---|
{{SpecName('HTML WHATWG', "media.html#event-media-progress", "progress media event")}} | {{Spec2('HTML WHATWG')}} |
{{SpecName('HTML5 W3C', "embedded-content-0.html#event-media-progress", "progress media event")}} | {{Spec2('HTML5 W3C')}} |
{{Compat("api.HTMLMediaElement.progress_event")}}