|
发表于 2024-12-2 11:29:40
|
显示全部楼层
IP:湖北
本帖最后由 起个网名好难 于 2024-12-2 18:30 编辑
- <style type="text/css">
- .mnBox {
- position: absolute;
- background: #333 url('https://cccimg.com/view.php/e68c0b4f52ae99ad435dd77ade371a98.jpg') no-repeat center/cover;
- height: 620px;
- width: 1286px;
- overflow: hidden;
- margin-top:90px;
- border: 1px solid;
- box-shadow: 0px 0px 0px 2px tan;
- left:50%;transform: translate(-50%);
- }
-
- .rain {
- width: 1px;
- height: 8px;
- top: -20px;
- left: 400px;
- background: #eee;
- position: relative;
- display: block;
- animation: rain 0.5s linear infinite;
- }
-
- .rain::before, .rain::after{
- content: "";
- position: absolute;
- left: 10px;
- top: -120px;
- width: 1px;
- height: 15px;
- background: #eee;
- }
-
-
-
- .circle {
- position:absolute;
- width: 3px;
- height: 1px;
- left: 85px;
- top: 90%;
- background:none;
- border: 1px solid #FFF;
- border-radius: 50%;
- animation:circle 2s ease-out infinite;
- }
-
- @keyframes circle {
- 0% { width:0; height:0; }
- 50% { opacity:0.1; width:2%; height:2%; }
- 60% { opacity:0.2; width:2%; height:2%; }
- 100% { opacity:0; width:2%; height:2%; }
- }
-
- @keyframes rain {
- 0% { opacity:0.5; }
- 100% { opacity:0.5; top:40%; }
- }
- #player {
- position: absolute;z-index: 40;
- left:35px;
- bottom: 50px;
- width: 150px;
- height: 150px;
- opacity: 1;
- transition: .4s;
- display: grid;
- place-items: center;
- --sp1: 0; --sp2: 1;
- }
- #player::before, #player::after {
- position: absolute;
- content: '';
- cursor: pointer;
- transition: .4s;
- }
- #player::before {width: 150px;height: 150px;background:url(https://cccimg.com/view.php/98bdbaeb6a57278824a651eb414e2188.png)no-repeat center/cover;
- opacity: var(--sp1);}
- #player::after {width: 150px;height: 150px;background:url(https://cccimg.com/view.php/98bdbaeb6a57278824a651eb414e2188.png)no-repeat center/cover;
- opacity: var(--sp2);}
- #phone{position: absolute;z-index: 5;width:60px;content: attr(data-lrc);margin-left:87%;margin-top:90px;display:inline-block;text-align: center; font:400 3.5em/1em 华文隶书; color:rgba(255,255,255,0.7);background:-webkit-linear-gra**nt(-180deg,rgba(255,255,255,0) 100px,rgba(255,255,255,1) 80px,rgba(255,255,255,1) 640px,rgba(255,255,255,0) 800px) 40px 0px no-repeat;-webkit-background-clip:text;filter:drop-shadow(#000 1px 0 0)drop-shadow(#000 0 1px 0)drop-shadow(#000 -1px 0 0) drop-shadow(#000 0 -1px 0);}
-
- #lrc {--state: paused;--motion: cover2;--tt: 2s;--bg: linear-gra**nt(0deg, #880000, #880000, #880000);
- position: absolute;z-index: 6;left: 50%; top: 80%;transform: translate(-50%);font:normal 3.5em 华文隶书; font-weight:400;color: #000080;white-space: pre;-webkit-background-clip: text;filter:drop-shadow(#FFFFFF 1px 0 0)drop-shadow(#FFFFFF 0 1px 0)drop-shadow(#FFFFFF -1px 0 0) drop-shadow(#FFFFFF 0 -1px 0);}
- #lrc::before {position: absolute;content: attr(data-lrc);width: 100%; height: 100%;color: transparent;overflow: hidden;white-space: pre;background: var(--bg);clip-path: inset(0 100% 0 0);-webkit-background-clip: text;animation: var(--motion) var(--tt) linear forwards;animation-play-state: var(--state);}
- @keyframes cover1{ to { clip-path: inset(0 0 0 0); } }@keyframes cover2 { to { clip-path: inset(0 0 0 0); } }
- </style>
- <div class="mnBox" id="mnBox">
- <div id="player" title="/" ></div>
- <div data-lrc="" id="lrc"></div>
-
- <div id="phone"><p style="font:400 0.8em/1.2em 华文隶书; width:25px;margin-left:12px;text-align: center;"></p></div>
- <span class="rain"></span>
- <span class="circle"></span>
- <audio id="aud" src="https://file.uhsea.com/2411/a84e33c0ac730a4a013f1fff084c539dOX.mp3" autoplay loop ></audio>
- </div>
- <div style="height:960px;"></div>
-
- <script >
- function rain() {
- var str = "";
- for(i=0; i<50; i++) {
- var l = Math.ceil(Math.random()*1286);
- str += "<span class='rain' style='left:" + l +"px;'></span>";
- }
- for(j=0;j<40; j++){
- var k1 = Math.ceil(Math.random()*100);
- var k2 = Math.round(Math.random()*40+70);
- str += "<span class='circle' style='left:" + k1 +"%;top:" + k2 +"%;'></span>";
- }
- document.getElementById('mnBox').innerHTML += str;
- }
-
- rain();
-
- let raindrops = mnBox.querySelectorAll('.rain');
- let rainpops = mnBox.querySelectorAll('.circle');
- let rainState = () => {
- aud.paused ? (raindrops.forEach( drop => {drop.style.animationPlayState='paused'}) , rainpops.forEach( pop => {pop.style.animationPlayState='paused'}))
- : (raindrops.forEach( drop => {drop.style.animationPlayState='running'}) , rainpops.forEach( pop => {pop.style.animationPlayState='running'}));
- }
-
-
- let mState = () => {rainState();aud.paused ? (player.style.setProperty('--sp1','1'), player.style.setProperty('--sp2','0')) : (player.style.setProperty('--sp1','0'), player.style.setProperty('--sp2','1'))};
-
- aud.addEventListener('play', () => mState());
- aud.addEventListener('pause', () => mState());
- player.addEventListener('click', () => aud.paused ? aud.play() : aud.pause());
-
- </script>
- <script >
- (function() {
- /*原始lrc歌词*/
- let lrcStr = `[00:00.000]走在冷雨里(Live 合唱版)-艺凌
- [00:02.802]词曲:隔壁老陈
- [00:05.604]编曲:李胜华
- [00:08.406]合唱:毅然合唱团
- [00:11.208]混音:毅然音乐
- [00:14.010]制作人:陈金文
- [00:16.812]LRC:老谟深虑
- [00:19.620]走在冷雨里
- [00:24.600]苦苦找寻往日的甜蜜
- [00:30.930]冷风一阵阵
- [00:35.880]吹不散我心中的忧虑
- [00:42.210]为什么你要狠心地离去
- [00:47.940]我不明白错在了哪里
- [00:53.550]如果我伤了你
- [00:56.400]不是我故意
- [00:59.190]我真的爱你不想放弃
- [01:02.010]只想和你在一起
- [01:04.830]求求你不要不要再生气
- [01:10.440]快快回到我的怀抱里
- [01:33.060]走在冷雨里
- [01:37.980]苦苦找寻往日的甜蜜
- [01:44.310]凄风一阵阵
- [01:49.260]吹不散我心中的忧虑
- [01:55.650]为什么你要把我来抛弃
- [02:01.320]你给我太多太多的回忆
- [02:06.960]如果我伤了你
- [02:09.780]不是我故意
- [02:12.630]我真的爱你真的想你
- [02:15.420]只盼情缘能再续
- [02:18.240]求求你不要不要再怀疑
- [02:23.880]我的生命里不能没有你
- [02:52.140]为什么你要把我来抛弃
- [02:57.810]你给我太多太多的回忆
- [03:03.420]如果我伤了你
- [03:06.270]不是我故意
- [03:09.090]我真的爱你真的想你
- [03:11.910]只盼情缘能再续
- [03:14.670]求求你不要不要再怀疑
- [03:20.370]我的生命里不能没有你
- `;
- /*变量 :mKey - 当前歌词索引;mFlag :调用关键帧动画索引;averAdd :平均值补偿*/
- let mKey = 0, mFlag = true, averAdd = 0.3;
-
- /*函数 :获取每句歌词用时,歌词用时若超过平均值则取平均值,最后一句歌词则取平均值*/
- let lrcTime = (ar) => {
- let tmpAr = [];
- for(j = 0; j <ar.length - 1; j ++) {
- if(j !== ar.length - 1) tmpAr[j] = parseFloat((ar[j+1][0] - ar[j][0]).toFixed(1));
- }
- let aver = parseInt(tmpAr.reduce((a,b) => a + b) / (tmpAr.length - 1)) + averAdd;
- tmpAr.push(aver);
- tmpAr.forEach((item,key) => {
- ar[key][2] = item > aver ? aver : item;
- });
- return ar;
- };
-
- /*函数 :从原始lrc歌词获取信息并存入 n*3 数组*/
- let getLrcAr = (text) => {
- let lrcAr = [];
- let calcRule = [60,1,0.001];
- for(x of text.split('\n')) {
- let ar = [];
- let re = /\d+[\.:]\d+([\.:]\d+)?/g;
- let geci = x.replace(re,'');
- if(geci) {
- geci = geci.replace(/[\[\]\'"\t,]s?/g,'');
- let time = x.match(re);
- if(time != null) {
- for(y of time) {
- let tmp = y.match(/\d+/g);
- let sec = 0;
- for(z in tmp) sec += tmp[z] * calcRule[z];
- ar[0] = [parseFloat(sec.toFixed(2)), geci];
- lrcAr.push(ar[0]);
- }
- }
- }
- }
- lrcAr.sort((a,b)=> a[0] - b[0]);
- return(lrcTime(lrcAr));
- };
-
- /*函数 :模拟显示同步歌词*/
- let showLrc = (time) => {
- let name = mFlag ? 'cover1' : 'cover2';
- lrc.innerHTML = lrcAr[mKey][1];
- 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;
- };
-
- /*函数 :处理当前歌词索引 mKey*/
- 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;
- }
-
- /*函数 :关键帧动画状态切换*/
- let mState = () => aud.paused ? (lrc.style.setProperty('--state','paused'),player.style.animationPlayState = 'paused') : (lrc.style.setProperty('--state','running'),player.style.animationPlayState = 'running');
-
- /*监听播放进度*/
- aud.addEventListener('timeupdate', () => {
- for (j = 0; j < lrcAr.length; j++) {
- if (aud.currentTime >= lrcAr[j][0]) {
- cKey = j;
- if (mKey === j) showLrc(lrcAr[j][2]);
- else continue;
- }
- }
- });
- aud.addEventListener('pause', () => mState());/*监听暂停事件*/
- aud.addEventListener('play', () => mState());/*监听播放事件*/
- aud.addEventListener('seeked', () => calcKey());/*监听查询事件*/
- let lrcAr = getLrcAr(lrcStr); /*获得歌词数组*/
- })();
- </script>
- <script>
- var ph=document.getElementById("phone");
- var otime=null;
- var num=-100;
- function tomove(){ if(!aud.paused){
- otime=setInterval(function (){
- num+=10;
- if(num==1100)
- {
- num=-100;
- clearInterval(otime);
- }
- ph.style.backgroundPosition=num+"px 0px";
-
- },20)}
- }
- tomove();
- setInterval(function(){
- tomove();
- },2000);
- </script>
复制代码
|
|