|
|

楼主 |
发表于 2022-10-20 07:19
|
显示全部楼层
代码
- <style>
- #papa { margin: auto; width: 1024px; height: 640px; background: url('https://638183.freep.cn/638183/t22/webp/hzbr.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: .15; }
- #papa::before { position: absolute; content: ''; width: 100%; height: 100%; background: url('https://638183.freep.cn/638183/t22/webp/126.gif') repeat; opacity: var(--opt); }
- #mplayer { position: absolute; bottom: 20px; display: grid; grid-template-columns: auto auto; place-items: center; z-index: 9; }
- #btnplay { width: 30px; height: 30px; border-radius: 50%; background: tan linear-gradient(hsla(120,100%,90%,.6), hsla(0,100%,50%,.6)); cursor: pointer; animation: rot linear 3s infinite; }
- #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,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(60,100%,50%,.75),hsla(120,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">
- <span id="btnplay"></span>
- <svg id="iplay" width="300" height="20">
- <line id="track" x1="10" y1="10" x2="190" y2="10" stroke="hsla(60,40%,80%,0.5)" stroke-width="10" stroke-linecap="round" />
- <line id="prog" x1="10" y1="10" x2="190" y2="10" stroke="hsla(0,100%,50%,0.5)" stroke-width="10" stroke-dasharray="180" stroke-dashoffset="180" stroke-linecap="round" />
- <text id="audtime" x="200" y="15" font-size="14" fill="hsl(0,0%,100%)">00:00 | 00:00</text>
- </svg>
- </div>
- </div>
- <script>
- (function() {
- let len = track.getTotalLength(), aud = new Audio(), mKey = 0, mFlag = true;
- aud.src = 'http://www.kumeiwp.com/sub/filestores/2022/10/19/810379d3e2e195ffc9cb66b84938bd37.mp3';
- let lrcAr = [[0.02,"劉詩詩 - 何者般若",14.0],[14.02,"詞 : 陳曦 曲 : 董冬冬",6.0],[20.02,"記不得 就忘了我",3.2],[24.74,"只不過一時片刻",3.2],[29.32,"誰來過 有誰來過",3.2],[33.87,"吞苦果",2.0],[38.81,"參不透 人世娑婆",3.2],[43.42,"逃不脫 是非善惡",3.2],[48.23,"躲不過 又躲不過",3.2],[52.73,"因果",2.5],[57.64,"三相並寂 何者般若",3.6],[62.31,"難尋世間 悲苦喜樂",3.9],[67.04,"若可放過 若可解脫",3.8],[70.99,"方可得",3.0],[76.4,"至當不易 月升日落",3.7],[81.23,"綻放凋零 蘭因絮果",3.8],[85.77,"何必識破 何以問責",3.9],[90.59,"對錯",1.6],[114.08,"參不透 人世娑婆",3.6],[118.72,"逃不脫 是非善惡",3.6],[123.6,"躲不過 又躲不過",3.3],[127.99,"因果",3.0],[132.92,"三相並寂 何者般若",3.7],[137.49,"難尋世間 悲苦喜樂",3.8],[142.28,"若可放過 若可解脫",3.9],[146.22,"方可得",2.9],[151.71,"至當不易 月升日落",4.0],[156.55,"綻放凋零 蘭因絮果",3.8],[161.16,"何必識破 何以問責",3.6],[165.82,"對錯",2.0]];
- aud.loop = true;
- aud.autoplay = true;
- btnplay.style.animationPlayState = aud.paused ? 'paused' : 'running';
- btnplay.onclick = () => aud.paused ? aud.play() : aud.pause();
- aud.addEventListener('seeked', () => calcKey());
- prog.onclick = track.onclick = (e) => aud.currentTime = aud.duration * (e.offsetX - 10) / len;
- aud.addEventListener('pause', () =>mState());
- aud.addEventListener('play', () =>mState());
- aud.addEventListener('timeupdate', () => {prog.style.strokeDashoffset = len - aud.currentTime * len / aud.duration;audtime.textContent = 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','.15'));
- 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>
复制代码
|
评分
-
| 参与人数 1 | 威望 +50 |
金钱 +100 |
经验 +50 |
收起
理由
|
红影
| + 50 |
+ 100 |
+ 50 |
赞一个! |
查看全部评分
|