|
|

楼主 |
发表于 2022-10-19 07:19
|
显示全部楼层
参考代码
- <style>
- #papa { margin: auto; width: 1024px; height: 640px; background: silver url('https://638183.freep.cn/638183/t22/webp/quwy.webp') no-repeat center/cover; box-shadow: 3px 3px 20px #000; position: relative; display: grid; grid-template-rows: repeat(2, 4fr) 1fr; grid-template-columns: repeat(3, 1fr); grid-template-areas: '. . top' 'mid mid mid' 'foot foot foot'; user-select: none; z-index: 1; }
- #papa > div { position: relative; display: grid; }
- .pTop { grid-area: top; place-items: end start; }
- .pMid { grid-area: mid; place-items: end center; }
- .pFoot { grid-area: foot; place-items: center; }
- #mplayer { position: absolute; width: 400px; height: 60px; font: normal 14px sans-serif; z-index: 9; }
- #mplayer::before, #mplayer::after { position: absolute; width: 100%; height: 50%; color: snow; margin: 15px 0; }
- #mplayer::before { content: attr(data-cur); }
- #mplayer::after { content: attr(data-dur); text-align: right; }
- #btnplay { position: absolute; left: calc(50% - 15px); bottom: 25px; width: 30px; height: 30px; border-radius: 50%; background: green url('https://638183.freep.cn/638183/t22/webp/lotus.webp') no-repeat; cursor: pointer; z-index: 2; animation: rot linear 4s infinite; }
- #prog { --posX: 0px; position: absolute; bottom: 10px; width: 100%; height: 1px; background: #eee; cursor: pointer; }
- #prog::before, #prog::after { position: absolute; content: ''; left: 0; }
- #prog::before { width: var(--posX); height: 1px; background: red; }
- #prog::after { left: var(--posX); top: calc(50% - 5px); width: 3px; height: 10px; background: silver; }
- #tit { position: absolute; bottom: 20px; right: 30px; font: bold 3em sans-serif; color: snow; text-shadow: 2px 2px 3px #212121; }
- #lrc { --motion: cover1; --tt: 1s; --state: paused; position: absolute; font: bold 2.4em sans-serif; color: hsl(240,100%,90%); -webkit-background-clip: text; filter: drop-shadow(1px 1px 2px hsla(0,100%,0%,.85)); }
- #lrc::before { position: absolute; content: attr(data-lrc); width: 20%; height: 100%; color: transparent; overflow: hidden; white-space: nowrap; background: linear-gradient(180deg,hsla(120,30%,50%,.75),hsla(120,100%,50%,.65)); 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%; } }
- @keyframes rot { to { transform: rotate(1turn); } }
- </style>
- <div id="papa">
- <div class="pTop"><img src="https://638183.freep.cn/638183/t22/webp/bird5.gif" alt="" style="mix-blend-mode: multiply;" /></div>
- <div class="pMid"><span id="lrc" data-lrc="花潮论坛lrc在线">花潮论坛lrc在线</span></div>
- <div class="pFoot">
- <div id="mplayer" data-cur="00:00" data-dur="00:00"><span id="prog"></span><span id="btnplay"></span></div>
- </div>
- </div>
- <script>
- (function() {
- let mKey = 0, mFlag = true, aud = new Audio();
- aud.src = 'http://www.kumeiwp.com/sub/filestores/2022/10/18/dbd937aed7a3070a1826bf4040426e11.mp3';
- let lrcAr = [ [0,"秋水无恙(演唱:五色石南叶 / 银临)",39.0], [39.05,"你仍侧脸成诗 凝望暮色不语",7.4], [46.99,"可知我心荒芜 仅扮作余晖",6.9], [54.95,"不经意的低头 喑哑了死局",6.6], [62.91,"以痴和妄来赎",5.8], [71.01,"如同宿命牵引 目光不期而遇",6.9], [78.98,"像千年的诗行 韵脚藏着谜",6.9], [86.99,"来不及说荣幸 岁月如梦初醒",6.7], [94.87,"抖落雪上足印",5.4], [102.16,"若一生尽头 能人潮对视",7.3], [111.07,"听你轻唤我小字如初",5.6], [118.05,"也不枉贪顾 山川曾抵足",7.9], [126.91,"命中执意生死总相负",6.0], [166.95,"剑底沧海倒影 笼着惊鸿一舞",7.0], [174.84,"隔夜再写收梢 任月色赤足",7.2], [182.93,"照这一双隐忍 如蜃景拂去",6.6], [190.8,"以余生望来路",5.5], [198.87,"年少梦里无光 唯你白衣如星",7.0], [206.85,"风月生平殊途 擦肩似谶语",6.8], [214.84,"相思两处耽搁 从来故地成墟",6.6], [222.8,"人间终无幸事",6.6], [230.13,"若一生尽头 能人潮对视",7.3], [238.96,"听你轻唤我小字如初",5.6], [246.03,"也不枉贪顾 山川曾抵足",7.4], [254.96,"命中执意生死总相负",6.0], [262.17,"看喜乐不舍 渐次上眉隙",7.2], [270.87,"教初雪吻过褶皱旧事",6.1], [278,"忆至柔软处 一笑泯千里",8.4], [286.97,"予你我半生疯魔痴心",6.2] ];
- aud.autoplay = true;
- aud.loop = true;
- if (aud.paused) btnplay.style.animationPlayState = 'paused';
- btnplay.onclick = () => aud.paused ? aud.play() : aud.pause();
- mplayer.onmousemove = (e) => {mplayer.style.cursor = e.offsetY > mplayer.offsetHeight / 1.5 ? 'pointer' : 'default';}
- mplayer.onclick = (e) => {if (e.offsetY > mplayer.offsetHeight / 1.5) aud.currentTime = aud.duration * e.offsetX / prog.offsetWidth;}
- aud.addEventListener('pause', () => mState());
- aud.addEventListener('play', () => mState());
- aud.addEventListener('seeked', () => calcKey());
- aud.addEventListener('timeupdate', () => {prog.style.setProperty('--posX', prog.offsetWidth * aud.currentTime / aud.duration + 'px');mplayer.dataset.cur = toMin(aud.currentTime);mplayer.dataset.dur = 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.animationPlayState = 'paused', lrc.style.setProperty('--state', 'paused')) : (btnplay.style.animationPlayState = 'running', 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; };
- papa.oncontextmenu = () => false;
- })();
- </script>
复制代码
|
|