; $(function(){ var timer1, timer2; var percent1, percent2; var playVideo1 = { init: function(){ clearInterval(timer1); timer1 = setInterval(playVideo1.getProgress,50); playVideo1.jump(); playVideo1.drag(); }, getProgress: function(){ var video = $("#bigVideo")[0], playPro = $("#playProgress"), nowLength = video.currentTime / video.duration; var progress = nowLength * ($("#progressWrap").width()) + "px"; playPro.css({"width":progress}); }, jump: function(){ $(".sectionVideo").off("mousedown").on("mousedown","#progressWrap",function(e){ var length = e.pageX - $("#progressWrap")[0].offsetLeft; percent1 = length / $("#progressWrap").width(); $("#bigVideo")[0].currentTime = percent1 * $("#bigVideo")[0].duration; $("#playProgress").css({"width":length}); }); }, drag: function(){ $("body").on("mousedown","#dragBox",function(e){ $("#bigVideo")[0].pause(); $(window).off("mousemove").on("mousemove",function(e){ var length = e.pageX - $("#progressWrap")[0].offsetLeft; percent1 = length / $("#progressWrap").width(); $("#bigVideo")[0].currentTime = percent1 * $("#bigVideo")[0].duration; $("#playProgress").css({"width":length}); $(window).off("mouseup").on("mouseup",function(e){ $(window).off("mousemove"); $("#bigVideo")[0].currentTime = percent1 * $("#bigVideo")[0].duration; $("#bigVideo")[0].play(); $("#bigVideo").parent().next(".cover").hide().next(".btnBox").hide(); $(window).off("mouseup"); }); }); }); } } var playVideo2 = { init: function(){ clearInterval(timer2); timer2 = setInterval(playVideo2.getProgress,50); playVideo2.jump(); playVideo2.drag(); }, getProgress: function(){ var video = $("#smallVideo")[0], playPro = $("#playProgress2"), nowLength = video.currentTime / video.duration; var progress = nowLength * ($("#progressWrap2").width()) + "px"; playPro.css({"width":progress}); }, jump: function(){ $(".sectionPlatform").off("mousedown").on("mousedown","#progressWrap2",function(e){ var length = e.pageX - $("#progressWrap2")[0].offsetLeft; percent2 = length / $("#progressWrap2").width(); $("#smallVideo")[0].currentTime = percent2 * $("#smallVideo")[0].duration; $("#playProgress2").css({"width":length}); }); }, drag: function(){ $("body").on("mousedown","#dragBox2",function(e){ $("#smallVideo")[0].pause(); $(window).off("mousemove").on("mousemove",function(e){ var length = e.pageX - $("#progressWrap2")[0].offsetLeft; percent2 = length / $("#progressWrap2").width(); $("#smallVideo")[0].currentTime = percent2* $("#smallVideo")[0].duration; $("#playProgress2").css({"width":length}); $(window).off("mouseup").on("mouseup",function(e){ $(window).off("mousemove"); $("#smallVideo")[0].currentTime = percent2 * $("#smallVideo")[0].duration; $("#smallVideo")[0].play(); $("#smallVideo").next(".cover").hide().next(".btnBox").hide(); $(window).off("mouseup"); }); }); }); } } playVideo1.init(); playVideo2.init(); });