ユーザがビデオ内の新しい位置に移動/スキップを完了したときに、テキストにより警告します:
var vid = document.getElementById("myVideo");
vid.onseeked = function() {
alert("Seek operation completed!");
};
Try it Yourself ❯
他の "Try it Yourself" の例が下にあります。
シークイベントが発生します。 seeked イベントは、ユーザがオーディオ/ビデオ内の新しい位置に、移動/スキップを終了したときに発生します。
チップ: seeked イベントは、seeking イベントの逆です。
チップ: 現在の再生位置を取得するには、オーディオ/ビデオ・オブジェクトの currentTime プロパティを使用します。
表中の数字は、イベントを完全にサポートした最初のブラウザ・バージョンを指定しています。
| イベント | |||||
|---|---|---|---|---|---|
| seeked | Yes | 9.0 | Yes | Yes | Yes |
HTML の場合:
<audio|video onseeked="myScript">Try it
JavaScript の場合:
audio|video.onseeked=function(){myScript};Try it
JavaScriptで、addEventListener() メソッドを使用する場合:
audio|video.addEventListener("seeked", myScript);Try it
注: addEventListener() メソッドは、 Internet Explorer 8 以前のバージョンではサポートしていません。
| サポートする HTML タグ: | <audio> および <video> |
|---|---|
| サポートするJavaScript オブジェクト: | Audio, Video |
この例では、seeking イベントと seeked イベントの違いを示しています。
<video onseeking="myFunction()" onseeked="mySecondFunction()">
Try it Yourself ❯
ユーザが新しい位置に移動/スキップを完了したときに、現在の再生時間位置を表示するために Video オブジェクトの currentTime プロパティを使用します:
// Get the <video> element with id="myVideo"
var vid =
document.getElementById("myVideo");
// Attach a seeked event to the
<video>, and execute a function when a seek operation completes
vid.addEventListener("seeked", myFunction);
function myFunction() {
// Display the current position of the <video> in a p element with id="demo"
document.getElementById("demo").innerHTML = vid.currentTime;
}
Try it Yourself ❯
ユーザがオーディオ内の新しい位置に移動/スキップを完了したときに、テキストにより警告します:
var aud = document.getElementById("myAudio");
aud.onseeked = function() {
alert("Seek operation completed!");
};
Try it Yourself ❯
HTML オーディオ/ビデオ DOM リファレンス