From 154b63534baf812bf9a5234774daf09952556285 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Wed, 8 Dec 2021 03:38:10 +0800 Subject: TSOP 2.7.1: help & format switching. Also finally removed all reminiscence of the legacy player. --- libs/music/player.d/main.js | 610 -------------------------------------------- 1 file changed, 610 deletions(-) delete mode 100644 libs/music/player.d/main.js (limited to 'libs/music/player.d/main.js') diff --git a/libs/music/player.d/main.js b/libs/music/player.d/main.js deleted file mode 100644 index 4795e5f..0000000 --- a/libs/music/player.d/main.js +++ /dev/null @@ -1,610 +0,0 @@ -var audio; -var playlist; -var tracks; -var current; -var mbuttonstate=0; -var plistshown=true; -var shuffle=0,repeat=0; -var plistRect; -var dpiratio=window.devicePixelRatio?window.devicePixelRatio:1; - -var audioCtxt=null; -var CtxtSource=null; -var CtxtAnalyser=null; -var canvas; -var CSpectrum=1024,CSpectrumIF=128; -var SpecWidth=0.7,SpecGap=0.08125; -var caps=[]; -var visualselector=null; -var SpecRingRadius=225; -var spectrogrampos=0; -var inkimg=[]; -var f1=0,f2=0,penv=0,btrig=0,beatp=0,lastbp=0; -var lpbd=300,lpf=1./(2*Math.PI*lpbd),beatr=0.02; -var frms=0,lastfpsupd=null,fps=0; -var ic1=["#FF3333","#FF8800","#FFFF00","#CCFF00","#33CCFF","#0000FF","#9966FF"]; -var ic2=["rgba(204,51,51,0.6)","rgba(187,85,0,0.6)","rgba(255,204,0,0.6)","rgba(153,204,0,0.6)","rgba(51,153,255,0.6)","rgba(0,0,102,0.6)","rgba(153,51,204,0.6)"] -var Ink=function(_vx,_vy,_c) -{ - this.x=canvas.width/2;this.y=canvas.height/2; - this.vx=_vx;this.vy=_vy; - this.color=_c>6?6:_c;this.active=true; -}; -Ink.prototype.update=function() -{ - this.x+=this.vx;this.y+=this.vy; - this.vx*=0.995;this.vy*=0.995; - if(this.x<-10||this.x>canvas.width+10||this.y<-10||this.y>canvas.height+10) - this.active=false; -} -Ink.prototype.draw=function(cctx) -{ - cctx.drawImage(inkimg[this.color],this.x+5*window.devicePixelRatio,this.y+5*window.devicePixelRatio); -} -var inks=[]; -function inkPrepare() -{ - for(var i=0;i<7;++i) - { - inkimg[i]=document.createElement('canvas'); - inkimg[i].width=inkimg[i].height=10*window.devicePixelRatio; - var cctx=inkimg[i].getContext('2d'); - cctx.fillStyle=ic1[i]; - cctx.beginPath(); - cctx.arc(5*window.devicePixelRatio,5*window.devicePixelRatio,3*window.devicePixelRatio,0,2*Math.PI); - cctx.fill(); - cctx.fillStyle=ic2[i]; - cctx.beginPath(); - cctx.arc(5*window.devicePixelRatio,5*window.devicePixelRatio,5*window.devicePixelRatio,0,2*Math.PI); - cctx.fill(); - } -} -function createInk(_vx,_vy,_c1,_c2) -{ - var f=false; - for(var i=0;i10)audio.currentTime=0; - else - { - current--; - if(current<0){ - current+=len; - if(shuffle)shufflePlist(); - link=playlist.find('a')[len-1]; - }else{ - link=playlist.find('a')[current]; - } - run($(link)); - } - } - document.getElementById("pbnext").onclick=function() - { - current++; - if(current==len){ - current=0; - if(shuffle)shufflePlist(); - link=playlist.find('a')[0]; - }else{ - link=playlist.find('a')[current]; - } - run($(link)); - } - switch(getcookie("playershuffle")) - { - case "1": - document.getElementById("shufflesw").innerHTML="On"; - document.cookie="playershuffle=1"; - shufflePlist(); - break; - default: - case "0": - document.getElementById("shufflesw").innerHTML="Off"; - document.cookie="playershuffle=0"; - sortPlist(); - break; - } - switch(getcookie("playerrepeat")) - { - case "1": - document.getElementById("repeatsw").innerHTML="On"; - document.cookie="playerrepeat=1"; - audio.loop=true; - break; - default: - case "0": - document.getElementById("repeatsw").innerHTML="Off"; - document.cookie="playerrepeat=0"; - audio.loop=false; - break; - } - if(getcookie("playervisualization").length!==0) - visualselector.value=getcookie("playervisualization"); - requestAnimationFrame(updateVisualization); -} -function shufflePlist() -{ - for(var i=0;ibs?1:asbs?1:as(window.innerHeight-383)) - { - changeImage('../../../koishi_hovr.png'); - document.getElementById("aqt").style.opacity="0.5"; - } - else - { - changeImage('../../../koishi_norm.png'); - document.getElementById("aqt").style.opacity="1.0"; - }*/ -} -function windowresize() -{ - if(plistshown) - { - document.getElementById("playlist").style.left=(window.innerWidth-plistRect.width)/2+"px"; - plistRect=document.getElementById("playlist").getBoundingClientRect(); - } - else - { - } -} -function run(link) -{ - var trurl=""; - if(window.location.href.indexOf("&title=")==-1) - trurl=window.location.href; - else - trurl=window.location.href.substr(0,window.location.href.indexOf("&title=")); - trurl=trurl.concat("&title="); - trurl=trurl.concat(link.attr('tr')); - window.history.replaceState("","The Stupid Online Player",trurl); - document.getElementById("imgplaypause").src="pause.svg"; - audio.src=link.attr('href'); - document.getElementById("nowplaying").innerHTML="Now Playing: "+link.attr('tr'); - par=link.parent(); - par.addClass('active').siblings().removeClass('active'); - audio.load(); - audio.play(); -} - -function togglePlist() -{ - document.getElementById("plistsw").onclick=function(){}; - plistshown=!plistshown; - if(plistshown) - { - for(var i=0;i0)--caps[i]; - color='hsl('+i*360.0/CSpectrum+',100%,25%)'; - cctx.fillStyle=color; - cctx.fillRect(i*(SpecWidth+SpecGap),canvas.height-(canvas.height*caps[i]/255.)-1,SpecWidth,1); - } - }catch(e){ - if(caps[i]>0)--caps[i]; - color='hsl('+i*360.0/CSpectrum+',100%,25%)'; - cctx.fillStyle=color; - cctx.fillRect(i*(SpecWidth+SpecGap),canvas.height-caps[i]-1,SpecWidth,1); - }; - } - if(visualselector.value=="spectrumring") - { - var cctx=canvas.getContext('2d'); - cctx.clearRect(0,0,canvas.width,canvas.height); - try{ - var freqarr=new Uint8Array(CtxtAnalyser.frequencyBinCount); - CtxtAnalyser.getByteFrequencyData(freqarr); - for(var i=0;i0)--caps[i]; - color='hsl('+i*360.0/CSpectrum+',100%,25%)'; - cctx.strokeStyle=color; - cctx.beginPath(); - cctx.moveTo(canvas.width/2.-Math.cos(2*Math.PI*(i/CSpectrum))*SpecRingRadius*(caps[i]+1)/255., - canvas.height/2.-Math.sin(2*Math.PI*(i/CSpectrum))*SpecRingRadius*(caps[i]+1)/255.); - cctx.lineTo(canvas.width/2.-Math.cos(2*Math.PI*(i/CSpectrum))*SpecRingRadius*caps[i]/255., - canvas.height/2.-Math.sin(2*Math.PI*(i/CSpectrum))*SpecRingRadius*caps[i]/255.); - cctx.stroke(); - } - }catch(e){ - if(caps[i]>0)--caps[i]; - color='hsl('+i*360.0/CSpectrum+',100%,25%)'; - cctx.strokeStyle=color; - cctx.moveTo(canvas.width/2.-Math.cos(2*Math.PI*(i/CSpectrum))*SpecRingRadius*(caps[i]+1)/255., - canvas.height/2.-Math.sin(2*Math.PI*(i/CSpectrum))*SpecRingRadius*(caps[i]+1)/255.); - cctx.lineTo(canvas.width/2.-Math.cos(2*Math.PI*(i/CSpectrum))*SpecRingRadius*caps[i]/255., - canvas.height/2.-Math.sin(2*Math.PI*(i/CSpectrum))*SpecRingRadius*caps[i]/255.); - cctx.stroke(); - }; - } - if(visualselector.value=="scope") - { - var cctx=canvas.getContext('2d'); - cctx.clearRect(0,0,canvas.width,canvas.height); - try{ - var tdomainarr=new Uint8Array(CtxtAnalyser.frequencyBinCount); - CtxtAnalyser.getByteTimeDomainData(tdomainarr); - cctx.lineWidth=dpiratio; - cctx.strokeStyle="#000"; - cctx.beginPath(); - var x=0; - for(var i=0;i=1800)spectrogrampos=0; - }catch(e){ - }; - } - if(visualselector.value=="inkfountain") - { - var cctx=canvas.getContext('2d'),ts=Date.now(),tu; - cctx.clearRect(0,0,canvas.width,canvas.height); - ++frms;if(Date.now()-lastfpsupd>500){if(lastfpsupd)fps=1000*frms/(Date.now()-lastfpsupd),frms=0;lastfpsupd=Date.now();} - try{ - var freqarr=new Uint8Array(CtxtAnalyser.frequencyBinCount); - CtxtAnalyser.getByteFrequencyData(freqarr); - for(var i=0;i7) - { - var color=Math.floor(i*8.0/CSpectrumIF),rad=Math.random()*Math.PI*2; - var ndrops=(128-i)/128.*3+1;ndrops*=(r/128.);ndrops=Math.floor(ndrops);if(ndrops<1)ndrops=1; - for(var k=0;kcaps[i])caps[i]=r;else caps[i]-=2; - } - }catch(e){ - console.log(e.message); - }; - tu=Date.now(); - var aa=0; - for(var i=0;ipenv)penv=env;else{penv*=br;penv+=(1-br)*env;} - if(!btrig){if(penv>0.20)btrig=1;}else{if(penv<0.125)btrig=0;} - beatp=0;if(btrig&&!lastbp)beatp=1;lastbp=beatp; - if(beatp)document.body.style.transform='translateY(100px)';else document.body.style.transform='translateY(0px)'; - } - }catch(e){ - document.body.style.transform='translateY(0px)'; - }; - }else document.body.style.transform='none'; - if(visualselector.value!="none") - af=requestAnimationFrame(updateVisualization); -} -- cgit v1.2.3