|
|

楼主 |
发表于 2022-10-23 07:39
|
显示全部楼层
源码(全)
- <style>
- #papa { margin: auto; width: 1024px; height: 640px; background: url('https://638183.freep.cn/638183/t22/webp/sydaug.webp') no-repeat center/cover; box-shadow: 3px 3px 20px #000; position: relative; display: grid; place-items: center; user-select: none; z-index: 1; --opt: .25; }
- #papa::before { position: absolute; content: url('https://638183.freep.cn/638183/t22/webp/swk.webp'); width: 132px; height: 132px; left: 10px; top: 10px; border: 2px solid gold; transform: rotate(15deg); opacity: .4; }
- #mplayer { position: absolute; bottom: 10px; display: grid; grid-template-columns: auto auto auto; place-items: center; gap: 6px; user-select: none; }
- #btnplay { background: linear-gradient(120deg,black,orange); border-radius: 50%; width: 35px; height: 35px; cursor: pointer; animation: rot linear 3s infinite; }
- #prog { --ww: 0px; width: 300px; height: 12px; border: 1px solid green; border-radius: 6px; background: snow; opacity: .65; position: relative; }
- #prog::before { position: absolute; content: ''; width: var(--ww); height: 12px; border-radius: 6px; background: snow linear-gradient(90deg, orange, red); opacity: .65; }
- #audtime { font: normal 14px sans-serif; color: snow; }
- #lrc { --motion: cover1; --tt: 5s; --state: paused; position: absolute; bottom: 60px; font: bold 2.4em sans-serif; color: hsl(0,10%,90%); -webkit-background-clip: text; filter: drop-shadow(1px 1px 2px hsla(0,0%,0%,.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(60,100%,50%,.45),hsla(0,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">
- <img src="https://638183.freep.cn/638183/t22/webp/125.gif" alt="" style="position: absolute; top: 10px; right: 10px;border-radius: 40%" />
- <img src="https://638183.freep.cn/638183/t22/webp/sywuks.gif" alt="" id="swk" style="position: absolute; left: 510px; top: 220px; mix-blend-mode: difference; transition: all 1.2s;" />
- <div id="lrc" data-lrc="花潮lrc在线">花潮lrc在线</div>
- <div id="mplayer">
- <span id="btnplay"></span>
- <span id="prog"></span>
- <span id="audtime">00:00 | 00:00</span>
- </div>
- </div>
- <script>
- (function() {
- let aud = new Audio(), mKey = 0, mFlag = true, down = true;
- let lrcAr = [[0.09,"孙大剩 (歌手:白亮 / 赵静)",16.0],[16.07,"词 曲 : 白亮",7.1],[23.22,"从小你就想当一个盖世英雄",2.9],[27.03,"逢人便说长大后要大闹天宫",2.9],[30.27,"可长大后却发现自己 是那么平庸",4.6],[38.53,"你曾经做的那个征服世界的梦",3.0],[42.12,"就像个玩笑深藏在你记忆之中",3.0],[45.41,"生活在检验着你到底 是龙还是虫",4.8],[54.02,"你没有学会七十二变的神通",2.8],[57.5,"也没有学会满嘴鬼话的武功",3.0],[60.78,"你总是很难挤出一个 恰当的笑容",4.8],[69.18,"你三十岁的内心总还波涛汹涌",2.9],[72.63,"可说出的话却是那样言不由衷",3.0],[76.14,"听他们谈起梦想你努力 做哑装聋",4.8],[84.09,"你是别人口中碌碌无为的孙大剩",4.8],[91.97,"你是掉进人堆也找不见的孙大剩",4.8],[99.05,"孙大剩",1.2],[100.59,"你的爱人等你开着宝马去娶她 ~~~",4.8],[106.64,"孙大剩",1.2],[108.01,"你多想在那皋兰山下有一个家 ~~~",4.8],[114.38,"孙大剩",1.2],[115.89,"你也曾想过周游世界劈柴喂马",4.8],[122.05,"孙大剩",1.2],[123.48,"你期待中的摇钱树会生根发芽",4.8],[149.54,"你没有学会七十二变的神通",3.0],[153.47,"也没有学会满嘴鬼话的武功",3.2],[156.79,"你总是很难挤出一个 恰当的笑容",5.0],[165.21,"你三十岁的内心总还波涛汹涌",3.0],[168.91,"可说出的话却是那样言不由衷",3.0],[172.15,"听他们谈起梦想你努力 做哑装聋",4.8],[180.33,"你是别人口中碌碌无为的孙大剩",4.8],[187.95,"你是掉进人堆也找不见的孙大剩",4.8],[195.12,"孙大剩",1.2],[196.68,"你的爱人等你开着宝马去娶她 ~~~",4.8],[202.64,"孙大剩",1.2],[204.05,"你多想在那皋兰山下有一个家 ~~~",4.8],[210.33,"孙大剩",1.2],[211.9,"你也曾想过周游世界劈柴喂马",4.8],[218.05,"孙大剩",1.2],[219.44,"你期待中的摇钱树会生根发芽",4.8],[225.74,"孙大剩",1.2],[227.07,"你抱起那把落满了尘土的吉他",4.8],[233.31,"孙大剩",1.2],[234.65,"你想起从前和你同甘共苦的她",4.8],[241.01,"孙大剩",1.2],[242.36,"你说过要把世界打得满地找牙",4.8],[248.66,"孙大剩",1.2],[250.29,"你却张着嘴巴流着眼泪说不出话 ~~~",5.2],[259.97,"啊 ...... ……",45.3]];
- aud.src = 'https://music.163.com/song/media/outer/url?id=32628933.mp3';
- aud.loop = true;
- aud.autoplay = true;
- if(aud.paused) btnplay.style.animationPlayState = 'paused';
- btnplay.onclick = () => aud.paused ? aud.play() : aud.pause();
- let jump = () => {swk.style.transform = 'translateY(' + (down ? 150 : 0) + 'px)';down = !down;setTimeout(jump, 10000);};
- prog.onclick = (e) => aud.currentTime = aud.duration * e.offsetX / prog.offsetWidth;
- aud.addEventListener('seeked', () => calcKey());
- aud.addEventListener('pause', () =>mState());
- aud.addEventListener('play', () =>mState());
- aud.addEventListener('timeupdate', () => {let prg = aud.currentTime * prog.offsetWidth / aud.duration < 6 ? 6 : aud.currentTime * prog.offsetWidth / aud.duration;prog.style.setProperty('--ww', prg + 'px');audtime.innerText = toMin(aud.currentTime) + ' | ' + toMin(aud.duration);for(j=0; j<lrcAr.length; j++) {if(aud.currentTime >= lrcAr[j][0]) {cKey = j;if(mKey === j) showLrc(lrcAr[j][2]);else continue;}}});
- 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 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 mState = () => aud.paused ? (btnplay.style.animationPlayState='paused',lrc.style.setProperty('--state', 'paused'),papa.style.setProperty('--opt','0')) : (btnplay.style.animationPlayState='running', lrc.style.setProperty('--state', 'running'),papa.style.setProperty('--opt','.25'));
- 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;}
- setTimeout(jump, 10000);
- })();
- </script>
复制代码
|
|