videojs("mvideo").ready(function(){ var myPlayer = this; myPlayer.play(); var last = 0; myPlayer.on("timeupdate", function(){ var currentTime = this.currentTime(); if(currentTime - last > 10) { $.post('{:url("Course/xxx")}',{"course_id":"{$video.course_id}","catalog_id":"{$video.course_id}","video_id":"{$video.course_id}","video_time":currentTime,"total_time":this.duration()},function(data){ if(data.status == 1){ if(data.message != ''){ console.log("成功"); } }else{ console.log("失败"); } }); last = currentTime; } }); }); 当前播放时间:this.currentTime(); 剩余时长:this.remainingTime(); 总时间:this.duration(); 跳转到指定播放位置:this.currentTime(time); this.on("loadstart",function(){ console.log("开始请求数据 "); }) this.on("progress",function(){ console.log("正在请求数据 "); }) this.on("loadedmetadata",function(){ console.log("获取资源长度完成 ") }) this.on("canplaythrough",function(){ console.log("视频源数据加载完成") }) this.on("waiting", function(){ console.log("等待数据") }); this.on("play", function(){ console.log("视频开始播放") }); this.on("playing", function(){ console.log("视频播放中") }); this.on("pause", function(){ console.log("视频暂停播放") }); this.on("ended", function(){ console.log("视频播放结束"); }); this.on("error", function(){ console.log("加载错误") }); this.on("seeking",function(){ console.log("视频跳转中"); }) this.on("seeked",function(){ console.log("视频跳转结束"); }) this.on("ratechange", function(){ console.log("播放速率改变") }); this.on("timeupdate",function(){ console.log("播放时长改变"); }) this.on("volumechange",function(){ console.log("音量改变"); }) this.on("stalled",function(){ console.log("网速异常"); })
更多精彩内容:各种AI课程、技能课程、黑科技软件、网站小程序源码、副业小项目、PPT模板等精品素材、电商课程、推广引流课程等,尽在 天边资源网 。