Video currentTime属性用于设置或返回视频播放的当前位置。 Video currentTime属性以秒的形式返回视频播放位置。设置此属性后,播放跳至指定位置。
用法:
返回currentTime属性:videoObject.currentTime
设置currentTime属性:videoObject.currentTime = seconds
属性值:
seconds:用于以秒为单位指定视频播放的位置。
以下示例程序旨在说明video currentTime属性:
例:将时间位置设置为50秒。
HTML | DOM Video currentTime Property
h1 {
color:green;
}
h2 {
font-family:Impact;
}
body {
text-align:center;
}
GeeksforGeeks
Video currentTime Property
width="360"
height="240"
controls>
type="video/mp4">
type="video/ogg">
For setting the current video playback position,
double click the "Change Position" button.
type="button">
Change Position
var v = document.getElementById("Test_Video");
function My_Video() {
v.currentTime = 50;
}
输出:
在单击按钮之前:
单击按钮后:
支持的浏览器:HTML | DOM Video currentTime属性在下面列出:
谷歌浏览器
IE浏览器
Firefox
Opera
苹果Safari