为了账号安全,请及时绑定邮箱和手机立即绑定

以不同的时序和功能循环播放视频

以不同的时序和功能循环播放视频

qq_花开花谢_0 2019-04-18 14:15:14
我有2个功能,播放相同的视频,但具有不同的时间。我无法发挥使功能正常工作。看起来该功能不会重置其他功能我试图改变变量名称,但仍然改变点击的时间。var video = document.getElementById('videoElm');function playShortVideo() {  var starttime = 0; // start at 0 seconds  var endtime = 2; // stop at 2 seconds  video.addEventListener("timeupdate", function() {    if (this.currentTime >= endtime) {      this.currentTime = 0; // change time index here    }  }, false);  video.load();  video.play();}function playFullVideo() {var starttime = 0; // start at 0 secondsvar endtime = 24; // stop at 2 seconds  video.addEventListener("timeupdate", function() {    if (this.currentTime >= endtime) {      this.currentTime = 0; // change time index here    }  }, false);  video.load();  video.play();}//play short video by defaultplayShortVideo();//CLICK events var btnshort = $('.shortvideo');var btnfull = $('.fullvideo');btnshort.click(function() {    playShortVideo();});btnfull.click(function() {  playFullVideo();});<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><div>    <video id="videoElm" autoplay muted controls loop>    <source src="http://clips.vorwaerts-gmbh.de/VfE_html5.mp4" type="video/webm"></video> </div><button class="shortvideo">play 2 secs only</a><br><button class="fullvideo">loop full video</button>
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 471 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号