|
|

楼主 |
发表于 2022-10-4 07:50
|
显示全部楼层
帖子代码没有很特别的东东:
- <style>
- #papa { left: -214px; width: 1024px; height: 640px; background: url('https://638183.freep.cn/638183/Pic/81/zcool.webp') no-repeat 60px -140px/cover, url('https://638183.freep.cn/638183/Pic/81/8-4.webp') no-repeat center/cover; background-blend-mode: darken, saturation; box-shadow: 3px 3px 20px #000; display: grid; place-items: center; user-select: none; position: relative; z-index: 1; }
- #mplayer { position: absolute; left: 160px; bottom: 10px; }
- #btnwrap { display: block; fill: hsla(30, 20%, 80%, .9); cursor: pointer; }
- #btnwrap:hover { fill: hsla(30, 100%, 50%, .9); }
- #tmsg { fill: hsla(30, 0%, 50%, .9); stroke: none; font: bold 1em sans-serif; }
- #lrc { --motion: cover1; --tt: 5s; --state: paused; position: absolute; left: 300px; bottom: 25px; font: bold 2.4em sans-serif; color: hsl(30,50%,90%); -webkit-background-clip: text; filter: drop-shadow(1px 1px 2px hsla(30,10%,10%,.95)); }
- #lrc::before { position: absolute; content: attr(data-lrc); width: 20%; height: 100%; color: transparent; overflow: hidden; white-space: nowrap; background: linear-gradient(180deg,hsla(30,0%,0%,.95),hsla(30,0%,100%,.75)); filter: inherit; -webkit-background-clip: text; animation: var(--motion) var(--tt) linear forwards; animation-play-state: var(--state); }
- @keyframes cover1 { from { width: 0; } to { width: 100%; } }
- @keyframes cover2 { from { width: 0; } to { width: 100%; } }
- </style>
- <div id="papa">
- <div id="lrc" data-lrc="花潮论坛lrc在线">花潮论坛lrc在线</div>
- <svg id="mplayer" width="120" height="120">
- <g id="mama" transform="rotate(-90, 60, 60)" style="cursor: pointer;">
- <circle id="track" cx="60" cy="60" r="50" fill="none" stroke-width="10" stroke="hsla(30, 20%, 80%, .9)" />
- <circle id="prog" cx="60" cy="60" r="50" fill="none" stroke-width="6" stroke="hsla(30, 20%, 40%, .9)" />
- </g>
- <g id="btnwrap">
- <path id="btnplay" d="M 50 50,50 70,70, 60 z"></path>
- <path id="btnpause" d="M 52 50,52 70,57 70,57 50,52 50 z M 60 50,60 70,65 70,65 50,60 50 z"></path>
- <path d="M 57 50,60 50,60 70,57 70 z" fill="transparent" />
- </g>
- <path id="curPath" d="M 20 70 Q 60 0 100 70" fill="none" stroke="none"/>
- <path id="durPath" d="M 20 55 Q 60 110 100 55" fill="none" stroke="none"/>
- <g id="tmsg">
- <text x="34" y="0"><textPath id="curMsg" xlink:href="#curPath" dominant-baseline="text-after-edge">00:00</textPath></text>
- <text x="29" y="0"><textPath id="durMsg" xlink:href="#durPath" dominant-baseline="text-before-edge">00:00</textPath></text>
- </g>
- </svg>
- </div>
- <script>
- let mKey = 0, mSeek = false, mFlag = true, aud = new Audio();
- let lrcAr = [[0,"荒島( 詞曲唱 : 謝知非)",10.1],[10.1,"編曲:小皮 | 口琴:朱七",9.0],[19.06,"我聽見雨滴落下的聲音",5.6],[28.04,"一點一滴敲打我的心",4.5],[35.04,"我聽見午夜時分的清醒",5.4],[44.03,"沒有一條路通向你的心",4.6],[51.07,"我聽見一只盲目的蜻蜓",5.4],[60.04,"愛上一個空心玻璃瓶",4.4],[67.06,"我聽見冰雪融化的聲音",5.2],[76.03,"卻聽不見你風中的回音",4.3],[83.04,"我聽見了你的聲音",4.0],[87.07,"在最北的山頂",3.0],[91.05,"我聽見了你的回應",4.0],[95.08,"在最深的海底",3.3],[99.05,"我聽見了你的哭泣",3.6],[103.07,"在層層海浪裏",3.5],[107.05,"我聽見了你的決定",4.0],[111.07,"在飛鳥的夢裏",3.4],[133.08,"我聽見烏雲在彈奏風琴",5.4],[142.04,"像封沒了音訊的書信",5.4],[149.05,"我聽見黎明鍾聲在靠近",5.5],[158.04,"卻沒有人能帶著我逃離",4.4],[165.06,"我聽見一只擱淺的藍鯨",5.5],[174.04,"炸裂發出巨大的聲音",5.4],[181.01,"我聽見木炭燃燒的聲音",5.3],[190.03,"在火焰中留不滅的烙印",4.3],[197.02,"我聽不見你的聲音",4.0],[201.06,"在最北的山頂",3.2],[205.04,"我聽不見你的回音",4.0],[209.07,"在最深的海底",3.3],[213.04,"你聽不見我的哭泣",4.0],[217.07,"在層層海浪裏",3.4],[221.04,"你聽不見我的決定",4.0],[225.08,"在荒蕪的愛裏",3.5],[229.06,"我聽見了你的聲音",4.0],[233.07,"在最北的山頂",3.2],[237.05,"我聽見了你的回應",4.0],[241.07,"在最深的海底",3.7],[245.03,"我聽見了你的哭泣",4.0],[249.06,"在層層海浪裏",3.4],[253.03,"我聽見了你的決定",4.0],[257.07,"在飛鳥的夢裏",4.1]];
- let cc = { x: 1*track.getAttribute('cx'), y: 1*track.getAttribute('cy'), len: track.getTotalLength(),};
- prog.style.strokeDasharray = prog.style.strokeDashoffset =cc.len;
- aud.src = 'https://music.163.com/song/media/outer/url?id=412319476.mp3';
- aud.autoplay = true;
- aud.loop = true;
- btnwrap.onclick = () => aud.paused ? aud.play() : aud.pause();
- mama.onclick = (e) => {
- let deg = Math.atan2(e.offsetY - cc.y, e.offsetX - cc.x) * 180 / Math.PI;
- deg += (e.offsetX < cc.x && e.offsetY < cc.y) ? 450 : 90;
- aud.currentTime = aud.duration * deg / 360;
- };
- aud.addEventListener('pause', () => mState());
- aud.addEventListener('play', () => mState());
- aud.addEventListener('seeked', () => calcKey());
- aud.addEventListener('timeupdate', () => {prog.style.strokeDashoffset = cc.len - cc.len * aud.currentTime / aud.duration;curMsg.textContent = toMin(aud.currentTime);durMsg.textContent = toMin(aud.duration);for(j=0; j<lrcAr.length; j++) {if(aud.currentTime >= lrcAr[j][0]) {if(mKey === j) showLrc(lrcAr[j][2]);else continue;}}});
- let mState = () => aud.paused ? (btnplay.style.display = 'block', btnpause.style.display = 'none', lrc.style.setProperty('--state', 'paused')) : (btnplay.style.display = 'none', btnpause.style.display = 'block', lrc.style.setProperty('--state', 'running'));
- let showLrc = (time) => {let name = mFlag ? 'cover1' : 'cover2';lrc.innerHTML = lrc.dataset.lrc = lrcAr[mKey][1];lrc.style.setProperty('--motion', name);lrc.style.setProperty('--tt', time + 's');lrc.style.setProperty('--state', 'running');mKey += 1;mFlag = !mFlag;};
- let calcKey = () => {for(j = 0; j < lrcAr.length; j ++) {if(aud.currentTime <= lrcAr[j][0]) {mKey = j - 1;break;}}if(mKey <0) mKey = 0;if(mKey > lrcAr.length - 1) mKey = lrcAr.length - 1;let time = lrcAr[mKey][2] - (aud.currentTime - lrcAr[mKey][0]);showLrc(time);};
- 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;};
- mState();
- </script>
复制代码
|
|