焱鑫磊 发表于 2023-8-26 11:49

《想你想断肠》钰柃

本帖最后由 焱鑫磊 于 2023-8-26 11:49 编辑 <br /><br /><style>
#papa{ margin: 100px -280px;width: 1164px;box-shadow: 0px 0px 0px 2px #cccccc, 0px 0px 0px 6px #880000; overflow: hidden;height: 680px;background: url('https://pic.imgdb.cn/item/64e96c0c661c6c8e542daad6.jpg') no-repeat center/cover;border: 1px solid;display: grid;position: relative;z-index: 12345; --state: running;}
                              #mplayer { --prg: 0%; --track: tan; --prog: #A2A976;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: 45%;border-radius: 2%;z-index: 60;}
                                #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); } }
#mpu {--ww: 100%;--hh: 180px;--pinpu: linear-gradient(to top,darkgreen,snow);position: absolute;bottom: 0px;left:0px;width: var(--ww);height: var(--hh);display: flex;justify-content: center;align-items: flex-end;cursor: pointer;z-index: 2; animation:rotat 6s linear infinite;}
@keyframes rotat{0%{filter:hue-rotate(360deg)}100%{filter:hue-rotate(0deg)}}

.mLine {position: relative;margin: 0 3px 2px 0;width: 6px;height: 18px;background: linear-gradient(0deg, #11F60A 79%,rgba(48, 235, 10, 0.01) 80%);transition: .35s;opacity: 1;}
.mLine::before { position: absolute; content: ''; width: 100%; height:2px; background: orange; top: -6px; }

#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: 80%;
      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)}}
#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">
<span id="fullscreen">全屏观赏</span>
<div id="mpu" ></div>
<div id="lrc" data-lrc="花潮lrc在线">花潮lrc在线</div>
<div id="mplayer" data-tt="00:00&#10;00:00">
                                <span id="titP">《想你想断肠》钰柃</span>
                                <span id="btnP1" title="播放/暂停"></span>
                                <span id="btnP2" title="播放/暂停"></span>
                                <span id="progP" title="调节进度"></span>
                        </div>
                        <audio id="aud" src="https://i.mp3.wf/view.php/6661b0be8d3264806102abbe6a4c463a.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 = `
《想你想断肠》
词/曲/演唱:钰柃
LRC歌词制作:焱鑫磊
好久没有看见你的模样
有时还会想起你的过往
这次又走过了老地方
突然触痛心底的伤
那只乌篷船依旧晃啊晃
只是船长他换了个地方
以为你在船头摇着桨
一抬头却只是幻想
我想你啊想断肠
伤心泪水不停流淌
为什么你变了心
许下的誓言说忘就忘
我想你啊想断肠
你却搂着别人的肩膀
谁能治愈我的伤
谁还能把我放在心上
我想你啊想你想断肠
好久没有看见你的模样
有时还会想起你的过往
这次又走过了老地方
突然触痛心底的伤
那只乌篷船依旧晃啊晃
只是船长他换了个地方
以为你在船头摇着桨
一抬头却只是幻想
我想你啊想断肠
伤心泪水不停流淌
为什么你变了心
许下的誓言说忘就忘
我想你啊想断肠
你却搂着别人的肩膀
谁能治愈我的伤
谁还能把我放在心上
我想你啊想断肠
伤心泪水不停流淌
为什么你变了心
许下的誓言说忘就忘
我想你啊想断肠
你却搂着别人的肩膀
谁能治愈我的伤
谁还能把我放在心上
我想你啊想你想断肠
`;

/*变量 :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); /*获得歌词数组*/
})();
let fs = true;
      fullscreen.onclick = () => {
                fs ? (fullscreen.innerText = '退出全屏',papa.requestFullscreen()) : (fullscreen.innerText = '全屏观赏', document.exitFullscreen());
                fs = !fs;
      };

</script>
<script>
(function() {
(function(mkPlayer) {let defaults = {ypData: new Array(500).fill(0).map((v,k) => Math.floor(Math.random() * 200) + 10)};let playCode = (user_config) => {let data = Object.assign({}, defaults, user_config);mpu.style.cssText += data.player_css;aud.loop = false;let total = Math.ceil(mpu.offsetWidth / 6), ppnum = 0;let mKey = 0, mFlag = true;for(j=0; j<total; j++) {let el = document.createElement('span');el.className = 'mLine';mpu.appendChild(el);}let lines = document.querySelectorAll('.mLine');let max = Math.max.apply(null,data.ypData);let divide = max/mpu.offsetHeight, coe = 20/total/2, plus;let update = () => lines.forEach((item,key) => {plus = (key < total/2 ? key : total - key) * coe * 10;item.style.setProperty('height', Math.random() * (data.ypData - 30) / divide + plus + 'px');});aud.addEventListener('pause', () => mState());aud.addEventListener('play', () => mState());aud.addEventListener('ended', () => { mKey = 0; aud.play(); });aud.addEventListener('timeupdate', () => {ppnum ++;if(ppnum >= data.ypData.length) ppnum = 0;update();for (j = 0; j < data.lrcAr.length; j++) {if (aud.currentTime >= data.lrcAr) {cKey = j;if (mKey === j) showLrc(data.lrcAr);else continue;}}});let mState = () => aud.paused ? lrc.style.setProperty('--state','paused') : lrc.style.setProperty('--state','running');let showLrc = (time) => {let name = mFlag ? 'cover1' : 'cover2';lrc.innerHTML = data.lrcAr;mKey += 1;mFlag = !mFlag;};};mkPlayer.HCPlayer = playCode;})(this);
      let ypData = ;
        HCPlayer({ypData: ypData,
                player_css: '--ww: 100%; --pinpu: linear-gradient(to top,blue,lightblue); align-items: flex-end;',
        });
})();

mpu.style.animationPlayState = aud.paused ? 'paused' : 'running';
aud.addEventListener('playing', () =>mpu.style.animationPlayState = 'running');
aud.addEventListener('pause', () =>mpu.style.animationPlayState = 'paused');
</script>

小辣椒 发表于 2023-8-26 12:25

问好焱鑫磊,谢谢精彩的分享{:4_171:}

红影 发表于 2023-8-26 12:57

这个磁带配色好看,磁带播放器按钮和频谱都有透明度,让后面的背景也能透出来,漂亮。
暂停能让所有动态都能停止。{:4_204:}

红影 发表于 2023-8-26 12:57

很完美的制作,欣赏焱鑫磊好帖{:4_199:}

焱鑫磊 发表于 2023-8-26 16:03

小辣椒 发表于 2023-8-26 12:25
问好焱鑫磊,谢谢精彩的分享

问好小辣椒!{:4_187:}

焱鑫磊 发表于 2023-8-26 16:04

红影 发表于 2023-8-26 12:57
这个磁带配色好看,磁带播放器按钮和频谱都有透明度,让后面的背景也能透出来,漂亮。
暂停能让所有动态都 ...

问好红影!{:4_187:}

焱鑫磊 发表于 2023-8-26 16:04

红影 发表于 2023-8-26 12:57
很完美的制作,欣赏焱鑫磊好帖

红影好!{:4_204:}

红影 发表于 2023-8-26 16:28

焱鑫磊 发表于 2023-8-26 16:04
问好红影!

焱鑫磊的制作都很完美和成功,非常赞呢{:4_199:}

红影 发表于 2023-8-26 16:28

焱鑫磊 发表于 2023-8-26 16:04
红影好!

问好焱鑫磊,周日快乐{:4_187:}
页: [1]
查看完整版本: 《想你想断肠》钰柃