别错过 (DJ阿卓版) - 程jiajia【根据黑老师卡带代码改编】
本帖最后由 亚伦影音工作室 于 2023-8-18 21:22 编辑 <br /><br /><style>#papa{ margin: 100px -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%;}
#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)}}
#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="lrc" data-lrc="花潮lrc在线">花潮lrc在线</div>
<div id="mplayer" data-tt="00:00 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/music179626876.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 = `
别错过 (DJ阿卓版) - 程jiajia
词:程jiajia
曲:程jiajia
混音:DJ阿卓
推广:张作全@鲸鱼向海
把你的心给我 把你的爱给我
这样我才能大胆尝试有更多的把握
我要的也不多 你不要嫌我啰嗦
我只是十分害怕不小心与你错过
我们辗转几何 可结果又是如何
没有任何意义其实你根本没爱过我
脑袋空白在此刻 我写了这首歌
其实没什么舍不得
只是眼睛酸涩全是红色
把你的心给我 把你的爱给我
这样我才能大胆尝试有更多的把握
我要的也不多 你不要嫌我啰嗦
我只是十分害怕不小心与你错过
无处不在的难过 又是谁的过错
就此和你别过你会不会快乐
这次我终于解脱 等到了这一刻
其实没什么舍不得
好好学会得过且过
我们辗转几何 可结果又是如何
没有任何意义其实你根本没爱过我
脑袋空白在此刻 我写了这首歌
其实没什么舍不得
只是眼睛酸涩全是红色`;
/*变量 :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>
棒棒哒!{:4_187:} 这磁带的颜色设置倒是跟底图十分相配呢。欣赏亚伦老师好帖{:4_199:} 醉美水芙蓉 发表于 2023-8-18 21:32
亚伦老师可以再加上频谱吗?
没问题,这是初搞!
页:
[1]