怎样用js+html5兑现视频的播放控制
2个回答
展开全部
html5自带控制属性;
用jq操作视频添加.play()是播放。
操作.stop();
用jq操作视频添加.play()是播放。
操作.stop();
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
H5edu教育HTML5开发解答html5 代码:
<video width="640" height="480" controls="controls" id="video" controls preload='none' poster="">
js代码:
document.addEventListener("DOMContentLoaded", init, false);
function init() {
document._video = document.getElementById("video");
webm = document.getElementById("webm");
init_events();
init_properties();
setInterval(update_properties, 1000);
}
Function init_events(){
for (key in media_events) { //监听video的各个属性
document._video.addEventListener(key, capture, false);
}
}
Video 具有的属性:
var media_properties = [ "error", "src", "currentSrc", "networkState", "preload", "buffered", "readyState", "seeking", "currentTime","initialTime", "duration", "startOffsetTime", "paused", "defaultPlaybackRate", "playbackRate", "played", "seekable", "ended", "autoplay", "loop","controls", "volume", "muted" ];
用js控制和获取video的值方法:
设置当前播放的时间:setAttribute(media_properties[currentTime],’123’);
eval("document._video." + media_properties[currentTime]);
取视频时长:var r = eval("document._video." + media_properties[duration]);
Alert(r);
控制其他的属性可以用同样的方法。
<video width="640" height="480" controls="controls" id="video" controls preload='none' poster="">
js代码:
document.addEventListener("DOMContentLoaded", init, false);
function init() {
document._video = document.getElementById("video");
webm = document.getElementById("webm");
init_events();
init_properties();
setInterval(update_properties, 1000);
}
Function init_events(){
for (key in media_events) { //监听video的各个属性
document._video.addEventListener(key, capture, false);
}
}
Video 具有的属性:
var media_properties = [ "error", "src", "currentSrc", "networkState", "preload", "buffered", "readyState", "seeking", "currentTime","initialTime", "duration", "startOffsetTime", "paused", "defaultPlaybackRate", "playbackRate", "played", "seekable", "ended", "autoplay", "loop","controls", "volume", "muted" ];
用js控制和获取video的值方法:
设置当前播放的时间:setAttribute(media_properties[currentTime],’123’);
eval("document._video." + media_properties[currentTime]);
取视频时长:var r = eval("document._video." + media_properties[duration]);
Alert(r);
控制其他的属性可以用同样的方法。
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询