|
|

楼主 |
发表于 2022-10-13 07:35
|
显示全部楼层
完整代码
- <style>
- #papa { left: -214px; width: 1024px; height: 640px; background: snow url('https://638183.freep.cn/638183/t22/webp/fwtm.webp') no-repeat center/cover; display: grid; place-items: center; box-shadow: 3px 3px 20px #000; user-select: none; position: relative; }
- #mplayer { position: absolute; bottom: 5px; width: 400px; height: 60px; font: normal 14px sans-serif; }
- #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: conic-gradient(red, magenta, blue, aqua, lime, yellow, red); 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% - 6px); width: 10px; height: 10px; border-radius: 50%; background: pink; }
- #lrc { --motion: cover1; --tt: 5s; --state: paused; position: absolute; bottom: 80px; font: bold 2.4em sans-serif; color: hsl(0,10%,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(28,15%,50%,.75),hsla(28,100%,50%,.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%; } }
- @keyframes rot { to { transform: rotate(1turn); } }
- </style>
- <div id="papa">
- <div id="lrc" data-lrc="花潮lrc在线">花潮lrc在线</div>
- <div id="mplayer" data-cur="00:00" data-dur="00:00"><span id="prog"></span><span id="btnplay"></span></div>
- </div>
- <script>
- let mKey = 0, mFlag = true, aud = new Audio();
- let lrcAr = [[0.05,"云朵 - 飞天(Live)",0.0],[0.07,"作词:十一少",1.9],[2,"作曲:韩冰",13.1],[15.09,"我在晚霞弹起琵琶",3.4],[19.07,"思念化作飞天壁画",3.4],[23.07,"为你诵读妙手莲花在天崖 ——",6.8],[31.07,"寂寞流沙淹没繁华",3.5],[35.06,"守候化作飞天壁画",3.6],[39.06,"几世轮回鸣沙山下",3.7],[43.02,"等你经过的时差 ——",3.7],[56.06,"驼铃声起伏在丝路繁华",4.0],[60.04,"夕阳下映出 你侧面脸颊",4.0],[64.04,"有一种爱叫做青梅竹马",3.8],[68.06,"那誓言永远如铁不会风化 ——",5.8],[76.05,"莫高窟外的风不停的刮",3.6],[80.04,"箜篌声弹拨着西域的沙",3.7],[84.03,"谁的泪模糊了岁月年华",3.6],[88.04,"我虔诚描摹菩萨盼你回家 ——",5.8],[95.06,"屋檐下舞一曲浪淘沙",4.0],[99.08,"风铃与我对话",4.0],[103.07,"空回头泪掉下你在哪",4.0],[107.05,"我还在牵挂",4.0],[111.08,"我在晚霞弹起琵琶",3.4],[115.06,"思念化作飞天壁画",3.5],[119.06,"为你诵读妙手莲花在天崖 ——",6.8],[127.07,"寂寞流沙淹没繁华",3.8],[131.06,"守候化作飞天壁画",4.0],[135.06,"几世轮回鸣沙山下",3.7],[139.02,"等你经过的时差 ——",3.7],[164.04,"驼铃声起伏在丝路繁华",3.6],[168.03,"夕阳下映出你侧面脸颊",3.7],[172.03,"有一种爱叫做青梅竹马",3.8],[176.04,"那誓言永远如铁 不会风化 ——",5.6],[184.06,"莫高窟外的风不停的刮",3.4],[188.04,"箜篌声弹拨着西域的沙",3.4],[192.03,"谁的泪模糊了岁月年华",3.6],[196.04,"我虔诚描摹菩萨盼你回家",6.1],[203.06,"屋檐下舞一曲浪淘沙",4.0],[207.06,"风铃与我对话",3.6],[211.05,"空回头泪掉下你在哪",4.0],[215.05,"我还在牵挂",2.1],[219.06,"我在晚霞弹起琵琶",3.4],[223.06,"思念化作飞天壁画",3.5],[227.06,"为你诵读妙手莲花在天崖 ——",6.8],[235.06,"寂寞流沙淹没繁华",3.3],[239.06,"守候化作飞天壁画",3.6],[243.06,"几世轮回鸣沙山下",3.6],[247.01,"等你经过的时差 ——",3.7],[251.08,"我在晚霞弹起琵琶",3.4],[255.06,"思念化作飞天壁画",3.7],[259.06,"为你诵读妙手莲花在天崖 ——",6.8],[267.08,"寂寞流沙淹没繁华",3.5],[271.06,"守候化作飞天壁画",3.8],[275.06,"几世轮回鸣沙山下",3.6],[279.02,"等你经过的时差 ——",3.7]];
- aud.src = 'http://www.kumeiwp.com/sub/filestores/2021/03/17/02d99f4ec6fb3170e3ab54d24dfda321.mp3';
- 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>
复制代码
|
评分
-
| 参与人数 1 | 威望 +50 |
金钱 +100 |
经验 +50 |
收起
理由
|
红影
| + 50 |
+ 100 |
+ 50 |
赞一个! |
查看全部评分
|