教程集 www.jiaochengji.com
教程集 >  前端编程  >  HTML5教程  >  正文 html5 video如何实现实时监测当前播放时间(代码)

html5 video如何实现实时监测当前播放时间(代码)

发布时间:2020-05-29   编辑:jiaochengji.com
教程集为您提供html5 video如何实现实时监测当前播放时间(代码)等资源,欢迎您收藏本站,我们将为您提供最新的html5 video如何实现实时监测当前播放时间(代码)资源
这篇文章给大家介绍的内容是关于html5 video如何实现实时监测当前播放时间(代码),有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。

html:

<video id="video" controls autoplay="autoplay" muted>
	<source src="" type="video/mp4" />
	Your browser does not support the video tag.
</video>

js:

//监听播放时间
var video = document.getElementById('video');
//使用事件监听方式捕捉事件
video.addEventListener("timeupdate",function(){
    var timeDisplay;
	//用秒数来显示当前播放进度
	timeDisplay = Math.floor(video.currentTime);
	console.log(Math.floor(video.currentTime))
    //当视频播放到 4s的时候做处理
	if(timeDisplay == 4){
	        //处理代码
	}
},false);

相关文章推荐:

html5中audio(音频)的分析

html5中video(视频)元素的分析

以上就是html5 video如何实现实时监测当前播放时间(代码)的详细内容,更多请关注教程集其它相关文章!

-->
  • 本文原创发布教程集,转载请注明出处,感谢您的尊重!
  • 您可能感兴趣的文章:
    html5 video如何实现实时监测当前播放时间(代码)
    html5的video(视频)和audio(音频)标签中的属性用法
    H5开发视频遇到的问题及解决方案
    HTML5 video标签的播放控制
    HTML5嵌入音频和视频的方法
    HTML5中video标签如何使用
    html5播放视频的标签是什么?如何在web页面播放视频呢?(内附实例)
    html5 canvas用来绘制弧形的代码实现
    如何解决HTML5微信播放全屏问题的方法
    h5 js如何实现视频播放?简单视频播放器控件的制作

    [关闭]
    ~ ~