亚伦影音工作室 发表于 2023-8-24 19:26

你总是如此如此如此的冷漠

<style>
#papa{ margin: 10px -300px;width: 1164px;box-shadow: 0px 0px 0px 2px #cccccc, 0px 0px 0px 6px #880000; overflow: hidden;height: 680px;background: url('https://img-baofun.zhhainiao.com/pcwallpaper_ugc/static/42014cb258802bb1fe7bc96506aedee3.jpg') no-repeat center/cover;border: 1px solid;display: grid;position: relative;z-index: 12345; --state: running;}
                              #mplayer { --prg: 0%; --track: tan; --prog: #ff0000;width: 200px; height: 120px; background: linear-gradient(to bottom, var(--track), var(--prog), transparent); box-shadow: 0 0 8px #666, 0 0 50px #999 inset, 0 0 20px #666; color: antiquewhite; font-size: 12px; display: grid; place-items: center; position: absolute;left: 10%;   top: 25%;border-radius: 2%; z-index: 666666;}
                                #mplayer > span { position: absolute; }
                                #mplayer::before, #mplayer::after, #mplayer > span::before, #mplayer > span::after { position: absolute; content: ''; }
                                #mplayer::before { left: 6px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: gray; box-shadow: 178px 0 0 gray, 0 98px 0 0 gray, 178px 98px 0 0 gray; }
                                #mplayer::after { content: attr(data-tt); white-space: pre; }
                                #btnP1, #btnP2 { width: 50px; height: 50px; border-radius: 50%; border: 1px solid silver; background: rgba(255,255,255,.5); display: grid; place-items: center; cursor: pointer; animation: rot 5s infinite linear var(--state); }
                                #btnP1 { left: 20px; }
                                #btnP2 { right: 20px; }
                                #btnP1::before, #btnP1::after, #btnP2::before, #btnP2::after { border-radius: 50%; }
                                #btnP1::before, #btnP2::before { width: 10px; height: 10px; border: 4px dotted #333; }
                                #btnP1::after, #btnP2::after { background: #333; min-width: 20px; min-height: 20px; max-width: 50px; max-height: 50px; -webkit-mask: radial-gradient(transparent 8px, red 0); }
                                #btnP1::after { width: calc(100% - var(--prg) + 10px); height: calc(100% - var(--prg) + 10px); }
                                #btnP2::after { width: calc(var(--prg) + 10px); height: calc(var(--prg) + 10px); }
                                #titP { top: 10px; }
                                #progP { width: 96%; height: 20px; bottom: 15px; background: linear-gradient(to right, var(--prog) var(--prg), var(--track) var(--prg), tan 0) repeat-x 0 50% / 100% 1px; cursor: pointer; }
                               
                                #btnFs { --color: white; --bg: #0089f0; position: absolute; color: var(--color); background: var(--bg); opacity: 0; border: 2px solid var(--color); border-radius: 8px; padding: 4px; transition: all .75s; cursor: pointer; z-index: 1000; }
                                @keyframes rot { to { transform: rotate(1turn); } }
                               
#lrc {
      --state: paused;
      --motion: cover2;
      --tt: 2s;
      --bg: linear-gradient(0deg, #ff0000, #ff0000, #ff0000);
      position: absolute;z-index: 6;
      left: 52%;
      transform: translate(-50%);
      top: 75%;
      font:normal 3em 华文新魏;
      font-weight:800;
      color: #0000;
      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 -1px0);
}
#lrc::before {
      position: absolute;
      content: attr(data-lrc);
      width: 20%;
      height: 100%;
      color: transparent;
      overflow: hidden;
      white-space: pre;
      background: var(--bg);
      
      -webkit-background-clip: text;
      animation: var(--motion) var(--tt) linear forwards;
      animation-play-state: var(--state);
}
@keyframes cover1{   0% { width: 100%;transform:rotate(0deg)scale(0)}100% { width: 100%;transform:rotate(0deg)scale(1);filter:hue-rotate(360deg)}}
@keyframes cover2 {    0% { width: 100%;transform:rotate(0deg)scale(0)}100% { width: 100%;transform:rotate(0deg)scale(1);filter:hue-rotate(360deg)}}
#img_border{width:100%;height:100%;position: absolute;animation: rotating 0.4s linear infinite;z-index: 3;}
@keyframes rotating{
0% {opacity: 1;transform: scale(0);}
50% {opacity: 1;transform: scale(1);filter:hue-rotate(360deg)contrast(150%);}
56% {opacity: 1;transform:scale(1.2);}
100% {opacity: 0;transform:scale(1.2);filter:hue-rotate(0deg)contrast(100%)brightness(850%);}}
#papa:hover #fullscreen { display:block ;}
#fullscreen { position: absolute; top:5%; left:83%;color:#ffffff; filter:drop-shadow( 1px 1px 1px #000000);font: normal 2.2em华文隶书; opacity: 1; cursor: pointer; z-index: 1111}
                        </style>
<div id="papa">
<imgid="img_border" src="http://image.hnol.net/c/2022-01/31/00/20220131005749121-5769293.png">
<span id="fullscreen">全屏观赏</span>

<div id="lrc" data-lrc="花潮lrc在线">花潮lrc在线</div>
<div id="mplayer" data-tt="00:00&#10;00:00">
                                <span id="titP">别错过(DJ阿卓版)</span>
                                <span id="btnP1" title="播放/暂停"></span>
                                <span id="btnP2" title="播放/暂停"></span>
                                <span id="progP" title="调节进度"></span>
                        </div>
                        <audio id="aud" src="https://www.qqmc.com/mp3/music228640352.mp3" autoplay="" loop=""></audio>
</div>
<script>
let toMin = (val) => { if (!val) return '00:00'; let min = parseInt(val / 60), sec = parseFloat(Math.floor(val) % 60); if(sec < 10) sec = '0' + sec; return min + ':' + sec; };
let mState = () => mplayer.style.setProperty('--state', aud.paused ? 'paused' : 'running');
aud.addEventListener('play', mState, false);
aud.addEventListener('pause', mState, false);
aud.addEventListener('timeupdate', () => {
      let prg = aud.currentTime / aud.duration * 100 + 20;
      mplayer.style.setProperty('--prg', prg + '%');
});
btnP1.onclick = btnP2.onclick = () => aud.paused ? aud.play() : aud.pause();
aud.addEventListener('timeupdate', () => { mplayer.style.setProperty('--prg', aud.currentTime / aud.duration * 100 + '%'); mplayer.dataset.tt = toMin(aud.currentTime) + '\n' + toMin(aud.duration); for (j = 0; j < data.lrcAr.length; j++) { if (aud.currentTime >= data.lrcAr) { if (mKey === j) showLrc(data.lrcAr); else continue; } } });
progP.onclick = (e) => aud.currentTime = e.offsetX * aud.duration / progP.offsetWidth;
</script>
<script >
(function() {
/*原始lrc歌词*/
let lrcStr = `
你总是如此如此如此的冷漠
我却是多么多么多么的寂寞
事隔多年你我各奔东西
我会永远把你留在生命里
我曾用心的来爱着你
为何不见你对我用真情
无数次在梦中与你相遇
惊醒之后你到底在哪里
不管时光如何被错过
如果这一走你是否会想起我
这种感觉往后日子不再有
别让这份情换成空
你总是如此如此如此的冷漠
我却是多么多么多么的寂寞
事隔多年你我各奔东西
我会永远把你留在生命里
我曾用心的来爱着你
为何不见你对我用真情
无数次在梦中与你相遇
惊醒之后你到底在哪里
不管时光如何被错过
如果这一走你是否会想起我
这种感觉往后日子不再有
别让这份情换成空
你总是如此如此如此的冷漠
我却是多么多么多么的寂寞
事隔多年你我各奔东西
我会永远把你留在生命里`;

/*变量 :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 = parseFloat((ar - ar).toFixed(1));
      }
      let aver = parseInt(tmpAr.reduce((a,b) => a + b) / (tmpAr.length - 1)) + averAdd;
      tmpAr.push(aver);
      tmpAr.forEach((item,key) => {
                ar = item > aver ? aver : item;
      });
      return ar;
};

/*函数 :从原始lrc歌词获取信息并存入 n*3 数组*/
let getLrcAr = (text) => {
      let lrcAr = [];
      let calcRule = ;
      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 * calcRule;
                                        ar = ;
                                        lrcAr.push(ar);
                              }
                        }
                }
      }
      lrcAr.sort((a,b)=> a - b);
      return(lrcTime(lrcAr));
};

/*函数 :模拟显示同步歌词*/
let showLrc = (time) => {
      let name = mFlag ? 'cover1' : 'cover2';
      lrc.innerHTML = lrcAr;
      lrc.dataset.lrc = lrcAr;
      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) {
                        mKey = j - 1;
                        break;
                }
      }
      if (mKey < 0) mKey = 0;
      if (mKey > lrcAr.length - 1) mKey = lrcAr.length - 1;
      let time = lrcAr - (aud.currentTime - lrcAr);
      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'),mplayer.style.animationPlayState = 'paused') : (lrc.style.setProperty('--state','running'),mplayer.style.animationPlayState = 'running');

/*监听播放进度*/
aud.addEventListener('timeupdate', () => {
      for (j = 0; j < lrcAr.length; j++) {
                if (aud.currentTime >= lrcAr) {
                        cKey = j;
                        if (mKey === j) showLrc(lrcAr);
                        else continue;
                }
      }
});
aud.addEventListener('pause', () => mState());/*监听暂停事件*/
aud.addEventListener('play', () => mState());/*监听播放事件*/
aud.addEventListener('seeked', () => calcKey());/*监听查询事件*/
let lrcAr = getLrcAr(lrcStr); /*获得歌词数组*/
})();

img_border.style.animationPlayState = aud.paused ? 'paused' : 'running';
aud.addEventListener('playing', () =>img_border.style.animationPlayState = 'running');
aud.addEventListener('pause', () =>img_border.style.animationPlayState = 'paused');
let fs = true;
      fullscreen.onclick = () => {
                fs ? (fullscreen.innerText = '退出全屏',papa.requestFullscreen()) : (fullscreen.innerText = '全屏观赏', document.exitFullscreen());
                fs = !fs;
      };
</script>

红影 发表于 2023-8-24 20:36

这效果真炫。欣赏亚伦老师好帖{:4_199:}
页: [1]
查看完整版本: 你总是如此如此如此的冷漠