// ==UserScript== // @name FloatingPlayer // @namespace https://greasyfork.org/zh-CN/scripts/449323/ // @version 0.9.1 // @description FloatingPlayer!悬浮窗 // @author Ylanty // @license GPLv3 // @match http*://*/* // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAE7mlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNy4xLWMwMDAgNzkuYTg3MzFiOSwgMjAyMS8wOS8wOS0wMDozNzozOCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczpkYz0iaHR0cDovL3B1cmwub3JnL2RjL2VsZW1lbnRzLzEuMS8iIHhtbG5zOnBob3Rvc2hvcD0iaHR0cDovL25zLmFkb2JlLmNvbS9waG90b3Nob3AvMS4wLyIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0RXZ0PSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VFdmVudCMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIDIzLjAgKFdpbmRvd3MpIiB4bXA6Q3JlYXRlRGF0ZT0iMjAyMi0wNy0yM1QyMTozMzo0MiswODowMCIgeG1wOk1vZGlmeURhdGU9IjIwMjItMDctMjlUMTY6NTk6MjgrMDg6MDAiIHhtcDpNZXRhZGF0YURhdGU9IjIwMjItMDctMjlUMTY6NTk6MjgrMDg6MDAiIGRjOmZvcm1hdD0iaW1hZ2UvcG5nIiBwaG90b3Nob3A6Q29sb3JNb2RlPSIzIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOmViNWUxNzAxLTIzNTYtYWI0NS1hNThhLWNjODA2NGRiZWQzYiIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDplYjVlMTcwMS0yMzU2LWFiNDUtYTU4YS1jYzgwNjRkYmVkM2IiIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDplYjVlMTcwMS0yMzU2LWFiNDUtYTU4YS1jYzgwNjRkYmVkM2IiPiA8eG1wTU06SGlzdG9yeT4gPHJkZjpTZXE+IDxyZGY6bGkgc3RFdnQ6YWN0aW9uPSJjcmVhdGVkIiBzdEV2dDppbnN0YW5jZUlEPSJ4bXAuaWlkOmViNWUxNzAxLTIzNTYtYWI0NS1hNThhLWNjODA2NGRiZWQzYiIgc3RFdnQ6d2hlbj0iMjAyMi0wNy0yM1QyMTozMzo0MiswODowMCIgc3RFdnQ6c29mdHdhcmVBZ2VudD0iQWRvYmUgUGhvdG9zaG9wIDIzLjAgKFdpbmRvd3MpIi8+IDwvcmRmOlNlcT4gPC94bXBNTTpIaXN0b3J5PiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PoBFavEAAAJ5SURBVEiJtZZNSFRRGIYfwyKYTSudJlfa2pkCEWtRlqFtLjZabkqkP9oEZRH9oQiVuIiMAhnMZeCNfsYxSTOTCSa1UjIqghJ/R8tQR0ObmWq+Fnab6XIdnTFfOHD4zj3vc97DOffeBBFhJbXKqLj5DvnX3/Dg3STf2r30nfRwzaqixEUQkX9aer0ot95Lq+jUNiJ9O5xyML1eFP2caM0QMB0IG/8Khfu+gMj5TnHEAjEEaIZnO6TGpkr+aY/cmPKHQW6vDOY0yOGlgKICNqmSr9WynVLSNix92thMUKSsS+qsi0CiAvQrTK8X5VyHOHwRW+gZE2+uS44ulMbwFC2k3iJcTYM02Zs55B5lAGCLGcu9PByFaRTYjE5aLAn0z13slNqZYDhN52cZ290oxyLnxZRAn8Y1QKP9EUc8Y4wAZCZjvptHTZaZrL/3Jt4E+jllXVKnnbSpgEi2U0qWlUCfxtlPQ8UrqgHWrYGcFHbBAq+KeBUSQlr/R4jgfwPYVJTCNAoqMigF8M5CyxAtAInLMbaqKBtMWGqzqchIIgnAF4Qzz7kw+5O5ZQFsKsq+jew9YWW/6Y/LkxE+Xenm8oSfyd4iXHEBrCqKxYTFsZ3yzGTMAJN+qOzh5uNhWjVjTTEBtL0utVGsrbpliA+VPVROBfDpzRcFJK6aH7eqKOtNmGu2UZ5lxgIw4YdL3VQ/HaHdyHhJAHsqe7beZ21BKrmnbBSbVs/XmwZ5W9VD1XSQmWjmgPFNjnz3R2p8TuT4M7kaywfH8B7c/shDfa2hn9f2Zg64R3EvuupoW9RbhMumgi+Ab2cKOV+/M+4awPXiCy9jMdaUICv82/IbKqHswvE0TmsAAAAASUVORK5CYII= // @downloadURL none // ==/UserScript== var run=1; //// @noframes (function() { 'use strict'; if(run>1) return; run++; var zindex=999999999; var maxrect=5,minrect=0.25,steprect=0.05,maxrspeed=10,fastwinds=20; var findedVideoElement=false,touchedVideoElement=false,floatingFlag=false,isIframe=false,isRotate=false,isFloatingbtnContainDisplay=false; var rotate=0; var screenSize=1,screenSizeChange=0,screenPosition='default'; var videoInfo={}; var videoratio={width:0,height:0}; var allElements={}; var containSize={width:0,height:0}; var cw,ch; var showSettingsT=null,showMsgT=null,onLongPress=null,doubleTouchT=null; var touchInfo={},mouseInfo={}; var floatingPlayerData = { //display: {name: '背景黑色',colspan: 2}, time: {name: '时间',colspan: 6,nolistener:true}, videorect: {name: '🗔'}, videorect_001: {name: -steprect*100+'%',value: -steprect}, videorectrange: {name: '滑动',colspan: 2,buttontype: 'range'}, videorect001: {name: '+'+steprect*100+'%',value: steprect}, videorectshow: {name: '100%'}, volume: {name: '🔊'}, volume_010: {name: '-10%',value: -0.1}, volumerange: {name: '滑动',colspan: 2,buttontype: 'range'}, volume010: {name: '+10%',value: 0.1}, volumeshow: {name: '100%'}, speed: {name: '倍速'}, speed_001: {name: '-x0.1',value: -0.1}, speedrange: {name: '滑动',colspan: 2,buttontype: 'range'}, speed001: {name: '+x0.1',value: 0.1}, speedshow: {name: 'x1.0'}, progress: {name: '进度'}, progress_001: {name: '-1%',value: -0.01}, progressrange: {name: '滑动',colspan: 2,buttontype: 'range'}, progress001: {name: '+1%',value: 0.01}, progressshow: {name: '100%'}, videoratio34: {name: '3:4'}, videoratio43: {name: '4:3'}, videoratio916: {name: '9:16'}, videoratio169: {name: '16:9'}, videoratioauto: {name: '拉伸'}, videoratiosource: {name: '原比'}, positionlefttop: {name: '◰'}, rotate: {name: '↻',value: 90}, positioncenter: {name: '⧈',colspan: 2}, rotate_: {name: '↺',value: -90}, positionrighttop: {name: '◳'}, positionleftbottom: {name: '◱'}, rewind: {name: '⏮ '+fastwinds+'s',value: -fastwinds}, play: {name: '⏵/⏸',colspan: 2}, fastwind: {name: '⏭ '+fastwinds+'s',value: fastwinds}, positionrightbottom: {name: '◲'} }; findVideoElement(); function findVideoElement(){ //alert(document.querySelector('iframe').contentWindow.document.querySelectorAll('video')); var k=0; var findVideoElementInterval = setInterval(function(){ if(document.querySelector('video')){ //alert(1); allElements.videoElement=document.querySelector('video'); if(allElements.videoElement.readyState >= 2){ //alert(window.top===window.self); if(window.top===window.self){ allElements.floatElement=allElements.videoElement; }else{ allElements.floatElement=window.top.document.querySelector('iframe'); isIframe=true; } allElements.floatElementContain=allElements.floatElement.parentElement; findedVideoElement=true; //clearInterval(findVideoElementInterval); if(window.top.document.querySelector('#fptlh')) window.top.document.querySelector('#fptlh').remove(); window.top.document.body.insertAdjacentHTML('beforeend',''); showFloatingBtn(); } } //k++; if(window.top.document.querySelector('#fptlh')){ var fptlh=window.top.document.querySelector('#fptlh'); if(fptlh.value==window.top.location.href) clearInterval(findVideoElementInterval); } }, 1000); } function isF(){ window.top.document.setValue('fptlh',window.top.location.href); } /*function findVideoElement(){ //alert(document.querySelector('iframe').contentWindow.document.querySelectorAll('video')); if(document.querySelector('video')){ //alert(1); allElements.videoElement=document.querySelector('video'); if(allElements.videoElement.readyState >= 2 && allElements.videoElement.duration>=20){ allElements.floatElement=allElements.videoElement; allElements.floatElementContain=allElements.floatElement.parentElement; findedVideoElement=true; } }else if(document.querySelector('iframe').contentWindow.document.querySelector('video')){ //alert(2); allElements.videoElement=document.querySelector('iframe').contentWindow.document.querySelector('video'); if(allElements.videoElement.readyState >= 2 && allElements.videoElement.duration>=20){ allElements.floatElement=document.querySelector('iframe'); //allElements.floatElement=allElements.videoElement; allElements.floatElementContain=allElements.floatElement.parentElement; findedVideoElement=true; isIframe=true; } } }*/ function showFloatingBtn(){ var btnCss=``; document.head.insertAdjacentHTML('beforeend',btnCss); //☫↻ //var floatingbtnstr='֎'; //var floatingvideostr=''; var floatingshowmsgstr=''; var floatingbtnContainstr='
'+floatingshowmsgstr+create_table()+'
'; allElements.floatElementRect=allElements.floatElement.getBoundingClientRect(); document.body.insertAdjacentHTML('beforeend',floatingbtnContainstr); //allElements.floatingbtnContain.append(allElements.floatElement); allElements.floatingbtnContain=document.getElementById('floatingbtnContain'); //allElements.floatingbtnContain.append(allElements.floatElement); floating(); if(isIframe){ //allElements.floatingbtnContain=window.top.document.getElementById('floatingbtnContain'); window.top.document.querySelector('head').insertAdjacentHTML('beforeend',''); }else{ allElements.floatingbtnContain.append(allElements.floatElement); } allElements.floatingshowmsg=document.getElementById('floatingshowmsg'); allElements.floatingplayer_setting=document.getElementById('floatingplayer_setting'); allElements.floatingplayer_setting_table=document.getElementById('floatingplayer_setting_table'); allElements.floatingbtnContain=document.getElementById('floatingbtnContain'); if(allElements.videoElement.paused) allElements.videoElement.play(); setEventListener(); //showFloatingInfo(); } function create_table() { const rows = 6; var htmlTable = ``; return htmlTable; } function floating(){ floatingFlag=floatingFlag?false:true; if(floatingFlag){ videoratio.width=allElements.videoElement.videoWidth; videoratio.height=allElements.videoElement.videoHeight; //var fw=cwvrfh/ch?vrfw/cw:vrfh/ch; //alert([cw,ch,vw,vh,vr,vrw,vrh,vrl,vrt,vrfw,vrfh,top,floatElement.querySelector('video')]); //allElements.floatingbtnContain.append(allElements.floatElementContain); //if(!isIframe) allElements.floatingbtnContain.append(allElements.floatElement); allElements.floatElement.className=''; allElements.videoElement.classList.add('floatingvideo'); /*if(!isIframe){ //allElements.videoElement.removeAttribute('controls'); //allElements.videoElement.className='floatingvideo'; allElements.videoElement.style=''; allElements.videoElement.id=''; //allElements.videoElement.controlsList='nofullscreen'; }*/ allElements.floatElement.style=''; allElements.floatElement.style.position='fixed'; allElements.floatElement.style.zIndex=zindex; if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) { screenSize=1; screenPosition='lefttop'; setFloatingVidooRect(); }else{ cw=window.top.document.documentElement.clientWidth; ch=window.top.document.documentElement.clientHeight; var vw=allElements.videoElement.videoWidth; var vh=allElements.videoElement.videoHeight; var vr=allElements.floatElementRect; var vrw=vr.width; var vrh=vr.height; var vrl=vr.left; var vrt=vr.top; var vrfw=vrwch-vrfh?ch-vrfh:vrt+(vrh-vrfh)/2); screenSize=vrfw/cw>vrfh/ch?vrfw/cw:vrfh/ch; //screenPosition='default'; allElements.floatElement.style.width=vrfw+'px'; allElements.floatElement.style.height=vrfh+'px'; allElements.floatElement.style.left=vrl+(vrw-vrfw)/2+'px'; allElements.floatElement.style.top=top+'px'; } }/*else{ allElements.videoElement.classList.remove('floatingvideo'); //floatElement.style=''; //if(!isIframe) allElements.floatElementContain.prepend(allElements.floatElement); allElements.floatElement.style.position=null; allElements.floatElement.style.zIndex=null; allElements.floatElement.style.width=null; allElements.floatElement.style.height=null; allElements.floatElement.style.left=null; allElements.floatElement.style.top=null; allElements.floatElement.removeEventListener("touchstart",touchStartHandler,true); allElements.floatElement.removeEventListener("mousedown",mouseDownHandler,true); }*/ } function setSettings(){ var vr=allElements.videoElement.getBoundingClientRect(); //cw=document.documentElement.clientWidth; //ch=document.documentElement.clientHeight; allElements.floatingplayer_setting.style.left=vr.left+'px'; allElements.floatingplayer_setting.style.top=vr.top+vr.height/2+'px'; allElements.floatingplayer_setting.style.maxWidth=vr.width+'px'; allElements.floatingplayer_setting.style.maxHeight=vr.height/2+'px'; allElements.floatingplayer_setting_table.style.width=vr.width+'px'; allElements.floatingplayer_setting_table.style.height=vr.height/2+'px'; } function showSettings(){ if(showSettingsT!=null) clearTimeout(showSettingsT); allElements.floatingplayer_setting.style.display='block'; setSettings(); showFloatingInfo(); showSettingsT = setTimeout(function() { showSettingsT=null; allElements.floatingplayer_setting.style.display='none'; }, 3000); } function showFloatingInfo(){ var showFloatingInfoInterval = setInterval(function(){ var ct=allElements.videoElement.currentTime; var dt=allElements.videoElement.duration; allElements.floatingplayer_time.textContent=secondsToTimeStr(ct)+'/'+secondsToTimeStr(dt); allElements.floatingplayer_videorectrange.value=(screenSize*100/maxrect).toFixed(0); allElements.floatingplayer_videorectshow.textContent=(screenSize*100).toFixed(0)+'%'; var progressbarvalue=ct/dt*100; allElements.floatingplayer_progressrange.value=(progressbarvalue).toFixed(0); allElements.floatingplayer_progressshow.textContent=(progressbarvalue).toFixed(0)+'%'; var speedanyvalue=allElements.videoElement.playbackRate; allElements.floatingplayer_speedrange.value=(speedanyvalue*100/maxrspeed).toFixed(0); allElements.floatingplayer_speedshow.textContent='x'+speedanyvalue.toFixed(1); var volumeanyvalue=allElements.videoElement.volume; allElements.floatingplayer_volumerange.value=(volumeanyvalue*100).toFixed(0); allElements.floatingplayer_volumeshow.textContent=(volumeanyvalue*100).toFixed(0)+'%'; if(allElements.floatingplayer_setting.style.display=='none'){ clearInterval(showFloatingInfoInterval); } }, 1000); } function showMsg(msg){ if(showMsgT!=null) clearTimeout(showMsgT); //setMsg(); var vr=allElements.videoElement.getBoundingClientRect(); allElements.floatingshowmsg.style.left=vr.left+'px'; allElements.floatingshowmsg.style.top=vr.top+'px'; allElements.floatingshowmsg.textContent=msg; allElements.floatingshowmsg.style.display='block'; showMsgT = setTimeout(function() { showMsgT=null; allElements.floatingshowmsg.style.display='none'; }, 2000); } function floatingVidooAttr(e){ //if(isIframe) videoElement=videoElementContain.querySelector('video'); var ele=e.target; var value=ele.value; var dataname=ele.getAttribute('dataname'); var datavalue=ele.getAttribute('datavalue'); var datatitle=ele.getAttribute('datatitle'); //alert([dataname,datavalue]); if(datavalue!='undefined') datavalue=parseFloat(datavalue); if(dataname=='display'){ isFloatingbtnContainDisplay=isFloatingbtnContainDisplay?false:true; if(isFloatingbtnContainDisplay){ allElements.floatingbtnContain.classList.add('floatingbtnContain_display'); }else{ allElements.floatingbtnContain.classList.remove('floatingbtnContain_display'); } }else if(dataname.substring(0,9)=='videorect'){ setVideoRect(dataname,datavalue,value); }else if(dataname.substring(0,8)=='progress'){ setProcess(dataname,datavalue,value); }else if(dataname.substring(0,5)=='speed'){ setSpeed(dataname,datavalue,value); }else if(dataname.substring(0,6)=='volume'){ setVolume(dataname,datavalue,value); }else if(dataname=='rewind' || dataname=='fastwind'){ allElements.videoElement.currentTime=allElements.videoElement.currentTime+datavalue; }else if(dataname=='play'){ allElements.videoElement.paused?allElements.videoElement.play():allElements.videoElement.pause(); }else if(dataname=='rotate' || dataname=='rotate_'){ screenSizeChange=0; rotate+=datavalue; if(rotate>=360) rotate-=360; else if(rotate<0) rotate+=360; allElements.floatElement.style.transform='rotate('+rotate+'deg)'; //allElements.floatingcontrols.style.transform='rotate('+rotate+'deg)'; /*floatingplayer_setting.style.transform='rotate('+rotate+'deg)';}*/ }else if(dataname.substring(0,8)=='position'){ screenPosition=dataname.substring(8); //setPosition(dataname); }else if(dataname.substring(0,10)=='videoratio'){ setVideoRatio(dataname); } if(dataname=='rotate' || dataname=='rotate_' || dataname.substring(0,5)=='video' || dataname.substring(0,8)=='position'){ setFloatingVidooRect(); } showSettings(); showMsg(datatitle); } function setVideoRect(dataname,datavalue,value){ if(dataname=='videorect'){ //setVideoRect(); }else if(dataname=='videorect_001' || dataname=='videorect001'){ var tempScreenSize=screenSize; screenSize+=datavalue; screenSize=screenSize>maxrect?maxrect:(screenSizemaxrspeed){ allElements.videoElement.playbackRate=maxrspeed; }else if(allElements.videoElement.playbackRate+datavalue<=0){ allElements.videoElement.playbackRate=0.1; }else{ allElements.videoElement.playbackRate+=datavalue; } }else if(dataname=='speedrange'){ allElements.videoElement.playbackRate=(value/100*maxrspeed).toFixed(1); } } function setVolume(dataname,datavalue,value){ if(dataname=='volume'){ allElements.videoElement.muted=allElements.videoElement.muted?false:true; }else if(dataname=='volume_010' || dataname=='volume010'){ if(allElements.videoElement.volume+datavalue>1) allElements.videoElement.volume=1; else if(allElements.videoElement.volume+datavalue<0) allElements.videoElement.volume=0; else allElements.videoElement.volume+=datavalue; }else if(dataname=='volumerange'){ allElements.videoElement.volume=value/100; }else if(dataname=='volumeshow'){ allElements.videoElement.muted=false; allElements.videoElement.volume=1; } } function setVideoRatio(dataname){ if(dataname=='videoratiosource'){ videoratio.width=allElements.videoElement.videoWidth; videoratio.height=allElements.videoElement.videoHeight; }else if(dataname=='videoratio34'){ videoratio.width=3; videoratio.height=4; }else if(dataname=='videoratio43'){ videoratio.width=4; videoratio.height=3; }else if(dataname=='videoratio916'){ videoratio.width=9; videoratio.height=16; }else if(dataname=='videoratio169'){ videoratio.width=16; videoratio.height=9; }else if(dataname=='videoratioauto'){ if(rotate==90||rotate==270){ videoratio.width=window.top.document.documentElement.clientHeight; videoratio.height=window.top.document.documentElement.clientWidth; }else{ videoratio.width=window.top.document.documentElement.clientWidth; videoratio.height=window.top.document.documentElement.clientHeight; } } } function setFloatingVidooRect(){ var left,top; cw=window.top.document.documentElement.clientWidth; ch=window.top.document.documentElement.clientHeight; var vw=videoratio.width; var vh=videoratio.height; var fw,fh; isRotate=rotate==90||rotate==270; if(isRotate){ fw=(ch0?hour+':':'')+(min < 10? '0' + min : min) + ':' + (sec < 10? '0' + sec : sec); return ret; } function setEventListener(){ if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) { allElements.videoElement.addEventListener("touchstart",videoEvent,true); }else{ allElements.videoElement.addEventListener("mouseover",videoEvent,true); allElements.videoElement.addEventListener("mousedown",videoEvent,true); } for (let index in floatingPlayerData) { allElements['floatingplayer_'+index]=document.getElementById('floatingplayer_'+index); if(!floatingPlayerData[index].nolistener){ allElements['floatingplayer_'+index].addEventListener(floatingPlayerData[index].buttontype?'input':'click', floatingVidooAttr,true); } } } function videoEvent(e){ var self=e; var ele=e.target; var etype=e.type; //ele.paused?ele.play():ele.play(); if(etype=='mouseover'){ videoInfo.scrollY=null; ele.addEventListener("mousewheel",videoEvent,true); ele.addEventListener("mouseleave",videoEvent,true); showSettings(); }else if(etype=='mousewheel'){ if(videoInfo.scrollY==null){ videoInfo.scrollY=window.top.scrollY; videoInfo.dw=window.top.document.documentElement.clientWidth; window.top.document.body.classList.add('fixedscroll'); window.top.document.body.style.top = `-${videoInfo.scrollY}px`; window.top.document.body.style.width = `${videoInfo.dw}px`; } var deltaY=self.deltaY; videoInfo.cx=self.clientX-ele.offsetLeft; videoInfo.cy=self.clientY-ele.offsetTop; videoInfo.ew=ele.offsetWidth; videoInfo.eh=ele.offsetHeight; var tempScreenSize=screenSize; var tempSizeChange=deltaY<0?-steprect:(deltaY>0?steprect:0); screenSize+=screenSize>2?tempSizeChange*2:tempSizeChange; screenSize=screenSize>maxrect?maxrect:(screenSizecx?fastwinds:-fastwinds; }else if(rotate==90){ temp=videoInfo.self.clientY>cy?fastwinds:-fastwinds; }else if(rotate==180){ temp=videoInfo.self.clientX>cx?-fastwinds:fastwinds; }else if(rotate==270){ temp=videoInfo.self.clientY>cy?-fastwinds:fastwinds; } ele.currentTime+=temp; showMsg('快进'+temp+'s'); } videoInfo.x=allElements.floatElement.offsetLeft-videoInfo.self.clientX; videoInfo.y=allElements.floatElement.offsetTop-videoInfo.self.clientY; if(etype=='touchstart'){ //videoInfo.startTouchFingers=e.touches.length; ele.addEventListener("touchend",videoEvent,true); ele.addEventListener("touchmove",videoEvent,true); }else{ ele.addEventListener("mouseleave",videoEvent,true); ele.addEventListener("mouseup",videoEvent,true); ele.addEventListener("mousemove",videoEvent,true); } }else if(etype=='touchmove' || etype=='mousemove'){ if(onLongPress!=null){ clearTimeout(onLongPress); onLongPress=null; ele.playbackRate=videoInfo.originalPlaybackRate; //showMsg(ele.playbackRate+'倍速播放'); } if (doubleTouchT != null){ clearTimeout(doubleTouchT); doubleTouchT = null; } //showSettings(e); screenPosition='mousemove'; videoInfo.self=etype=='touchmove'?self.touches[0]:self; allElements.floatElement.style.left=videoInfo.x+videoInfo.self.clientX+'px'; allElements.floatElement.style.top=videoInfo.y+videoInfo.self.clientY+'px'; setSettings(); }else if(etype=='touchend' || etype=='mouseup' || etype=='mouseleave'){ if(videoInfo.scrollY!=null){ window.top.document.body.classList.remove('fixedscroll'); window.top.document.body.style.top = `0px`; window.top.scrollTo({top:videoInfo.scrollY}); window.top.document.body.style.width = null; } if(onLongPress!=null){ clearTimeout(onLongPress); onLongPress=null; ele.playbackRate=videoInfo.originalPlaybackRate; //showMsg(ele.playbackRate+'倍速播放'); } videoInfo.self=null; videoInfo.x=null; videoInfo.y=null; if(etype=='touchend'){ ele.removeEventListener("touchmove",videoEvent,true); ele.removeEventListener("touchend",videoEvent,true); }else{ ele.removeEventListener("mousemove",videoEvent,true); ele.removeEventListener("mouseleave",videoEvent,true); ele.removeEventListener("mouseup",videoEvent,true); ele.removeEventListener("mousewheel",videoEvent,true); } } } // Your code here... })();