|
|

楼主 |
发表于 2022-9-6 07:54
|
显示全部楼层
代码:
- <style>
- #papa { left: -214px; width: 1024px; height: 640px; background: #666 url('/data/attachment/forum/202209/06/074904leqeezdkdihvu6w4.jpg') no-repeat center/cover; display: grid; place-items: center; box-shadow: 3px 3px 20px #000; user-select: none; position: relative; z-index: 1;}
- #mplayer { position: absolute;right: 100px; bottom: 20px; width: 120px; height: 120px; border-radius: 50%; overflow: hidden; }
- #track { stroke: url(#gradient); }
- #lrc { position: absolute; display: block; top: 20px; }
- #lrctxt { dominant-baseline: middle; fill: url(#gradient); font: bold 2.2em sans-serif; text-shadow: -2px -2px 0px snow, 2px 2px 3px #000; letter-spacing: 3px; }
- </style>
- <div id="papa">
- <div id="mplayer">
- <svg width="100%" height="100%" shape-rendering="geometricPrecision">
- <g transform="rotate(-90, 60, 60)">
- <circle id="track" cx="60" cy="60" r="55" fill="none" stroke="rgba(255,255,255,.5)" stroke-width="10" stroke-dasharray="2" stroke-opacity="0.35" />
- <circle id="prog" cx="60" cy="60" r="55" fill="none" stroke="red" stroke-width="3" stroke-opacity="0.65"/>
- </g>
- <text fill="orange">
- <tspan id="cur" x="40" y="55">00:00</tspan>
- <tspan id="dur" x="40" y="75">00:00</tspan>
- </text>
- </svg>
- </div>
- <svg id="lrc" width="410" height="150">
- <defs><path id="lrcPath" fill="none" stroke="red" d="M 20 20 Q 200 180 400 20" /></defs>
- <defs>
- <linearGradient id="gradient" x1="0" y1="0" x2="0" y2="1">
- <stop offset="0%" stop-color="blue"/>
- <stop offset="35%" stop-color="orange"/>
- <stop offset="65%" stop-color="gray"/>
- <stop offset="100%" stop-color="red"/>
- </linearGradient>
- </defs>
- <text x="0" y="20"><textPath id="lrctxt" xlink:href="#lrcPath">任然 - 空空如也</textPath></text>
- </svg>
- </div>
- <script>
- let lrcAr = [
- ['0.00','空空如也 - 任然'],
- ['14.06','熟悉的 陌生的 这种感觉'],
- ['17.04','重复的 曾经的 那些情节'],
- ['20.06','也只是 怀念'],
- ['26.07','一滴滴 一点点 一页一篇'],
- ['29.07','分手了 也不过 三百多天'],
- ['32.05','可我却 害怕遇见'],
- ['37.04','我懵懵懂懂过了一年'],
- ['40.04','这一年似乎没有改变'],
- ['43.05','守着你离开后的世界'],
- ['45.09','空 空如也'],
- ['49.06','白天和晚上都是冬夜'],
- ['52.06','悲伤的到来我从不拒绝'],
- ['57.03','反正亦是'],
- ['58.09','空空空空如也'],
- ['62.00','我懵懵懂懂过了一年'],
- ['65.01','徘徊在石板路的街边'],
- ['68.00','曾经笑容灿烂如今却'],
- ['70.05','空空如也'],
- ['74.02','一切的星光都已陨灭'],
- ['77.04','得过且过是我如今速写'],
- ['81.03','无所谓 让痛重叠'],
- ['111.05','我懵懵懂懂过了一年'],
- ['114.02','这一年似乎没有改变'],
- ['117.03','守着你离开后的世界'],
- ['119.07','空 空如也'],
- ['123.05','白天和晚上都是冬夜'],
- ['126.04','悲伤的到来我从不拒绝'],
- ['131.02','反正亦是'],
- ['132.08','空空空空如也'],
- ['135.09','我懵懵懂懂过了一年'],
- ['138.09','徘徊在石板路的街边'],
- ['141.09','曾经笑容灿烂如今却'],
- ['144.03','空空如也'],
- ['148.01','一切的星光都已陨灭'],
- ['151.00','得过且过是我如今速写'],
- ['155.01','无所谓 让痛重叠'],
- ['160.03','我懵懵懂懂过了一年'],
- ['163.05','这一年似乎没有改变'],
- ['166.07','守着你离开后的世界'],
- ['169.00','空 空如也'],
- ['172.08','白天和晚上都是冬夜'],
- ['175.08','悲伤的到来我从不拒绝'],
- ['180.04','反正亦是'],
- ['182.01','空空空空如也'],
- ['184.09','我懵懵懂懂过了一年'],
- ['188.01','徘徊在石板路的街边'],
- ['191.02','曾经笑容灿烂如今却'],
- ['193.05','空空如也'],
- ['197.04','一切的星光都已陨灭'],
- ['200.04','得过且过是我如今速写'],
- ['204.04','无所谓 让痛重叠']
- ];
- let aud = new Audio();
- aud.src = 'https://music.163.com/song/media/outer/url?id=526464293.mp3';
- aud.autoplay = true;
- aud.loop = true;
- let girth = prog.getTotalLength();
- prog.style.strokeDasharray = prog.style.strokeDashoffset = girth+ 'px';
- mplayer.onmousemove = (e) => {
- if (isHover(e.offsetX, e.offsetY)) mplayer.style.cursor = 'pointer';
- }
- mplayer.onclick = (e) => {
- if (isHover(e.offsetX, e.offsetY)) {
- let deg = Math.atan2(e.offsetY - 60, e.offsetX - 60) * 180 / Math.PI;
- deg += (e.offsetX < 60 && e.offsetY < 60) ? 450 : 90;
- aud.currentTime = aud.duration * deg / 360;
- } else {
- aud.paused ? aud.play() : aud.pause();
- }
- }
- aud.addEventListener('timeupdate', () => {
- prog.style.strokeDashoffset = girth - girth * aud.currentTime / aud.duration + 'px';
- cur.textContent = toMin(aud.currentTime);
- dur.textContent = toMin(aud.duration);
- for(j=0; j<lrcAr.length; j++) {
- if(aud.currentTime >= lrcAr[j][0]) lrctxt.textContent = lrcAr[j][1];
- }
- });
- let isHover = (x,y) => Math.pow(x - 60, 2) + Math.pow(y - 60, 2) >= Math.pow(45, 2);
- let toMin = (val) => {
- if (!val) return '00:00';
- val = Math.floor(val);
- let min = parseInt(val / 60), sec = parseFloat(val % 60);
- if(min < 10) min = '0' + min;
- if(sec < 10) sec = '0' + sec;
- return min + ':' + sec;
- }
- </script>
复制代码
|
|