目录

onseeking 事件

示例

当用户开始移动/跳到视频中的新位置时调用函数:

<video onseeking="myFunction()">
亲自试一试 »

下面有更多示例。


描述

这个onseeking当用户发生事件时开始寻找新职位在某媒体中。

音频和视频事件

加载媒体时,这些事件按以下顺序发生:

Event Occurs When
onloadstart The loading of a media starts
ondurationchange The duration of a media is changed
onloadedmetadata The meta data for a media has been loaded
onloadeddata A media frame is loaded
onprogress The browser is loading a media
oncanplay An element's scrollbar is being scrolled
oncanplaythrough The browser estimates it can play a media
onplay A media starts to play
onplaying A media starts or resumes
ontimeupdate The indicated time is changed
onended A media has reached the end

媒体加载或播放时可能发生的事件:

Event Occurs When
onabort The loading of a media is aborted
onemptied A media is empty (already loaded)
onerror An error occurs while loading a media
onpause A media is paused
onratechange The playback rate is changed
onseeked A user has seeked a new media position
onseeking A user start seeking a new media position
onstalled Media data is not available
onsuspend The browser is not getting the media data
onvolumechange The volume of a media is changed
onwaiting A media is waiting for the next frame

也可以看看:

<音频> 对象
<video> 对象



语法

在 HTML 中:

< element onseeking=" myScript">
亲自试一试 »

在 JavaScript 中:

object.onseeking = function(){ myScript};
亲自试一试 »

在 JavaScript 中,使用 addEventListener() 方法:

object.addEventListener("seeking", myScript);
亲自试一试 »

技术细节

气泡:
可取消:
事件类型: 事件
HTML 标签: <音频> 和 <视频>
DOM 版本: 3 级活动

更多示例

示例

此示例演示了 onseeking 事件和 onseeked 事件之间的区别:

<video onseeking="myFunction()" onseeked="mySecondFunction()">
亲自试一试 »

示例

当用户开始跳到新位置时,使用视频对象的 currentTime 属性显示当前播放时间位置:

// Get the <video> element:
const video = document.getElementById("myVideo");

// Attach a seeking event to the <video> element:
x.addEventListener("seeking", myFunction);

// Function to display the current position of the video:
function myFunction() {
    document.getElementById("demo").innerHTML = video.currentTime;
}
亲自试一试 »

示例

当用户开始在音频中寻找新位置时调用函数:

<audio onseeking="myFunction()">
亲自试一试 »

浏览器支持

onseeking是 DOM Level 3 (2004) 功能。

所有现代浏览器都完全支持它:

Chrome Edge Firefox Safari Opera IE
Yes Yes Yes Yes Yes 11