微尘
<style>#papa { left: -214px; width: 1024px; height: 640px; background: url('https://638183.freep.cn/638183/t22/webp/wwif.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: .25; }
#mplayer { position: absolute; bottom: 10px; display: grid; grid-template-columns: auto auto auto; place-items: center; gap: 6px; user-select: none; }
#btnplay { width: 40px; height: 40px; cursor: pointer; display: grid; place-items: center; animation: rot linear 3s infinite; position: relative; }
#btnplay > span { position: absolute; width: 10px; height: 10px; border-radius: 50%; background: linear-gradient(tan,red); }
#prog { --ww: 0px; width: 300px; height: 12px; border-radius: 6px; background: snow; opacity: .65; position: relative; }
#prog::before { position: absolute; content: ''; width: var(--ww); height: 12px; border-radius: 6px; background: snow linear-gradient(90deg, gray,orange); opacity: .65; }
#audtime { font: normal 14px sans-serif; color: snow; }
#lrc { --motion: cover1; --tt: 5s; --state: paused; position: absolute; top: 20px; font: bold 2.4em sans-serif; color: hsl(0,10%,90%); -webkit-background-clip: text; filter: drop-shadow(1px 1px 2px hsla(0,0%,0%,.95)); }
#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%,.45),hsla(200,50%,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">
<div id="btnplay"><span></span></div>
<span id="prog"></span>
<span id="audtime">00:00 | 00:00</span>
</div>
</div>
<script>
(function() {
let aud = new Audio(), mKey = 0, mFlag = true, down = true;
let lrcAr = [,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,];
aud.src = 'https://music.163.com/song/media/outer/url?id=1808295441.mp3';
aud.loop = true;
aud.autoplay = true;
if(aud.paused) btnplay.style.animationPlayState = 'paused';
btnplay.onclick = () => aud.paused ? aud.play() : aud.pause();
prog.onclick = (e) => aud.currentTime = aud.duration * e.offsetX / prog.offsetWidth;
aud.addEventListener('seeked', () => calcKey());
aud.addEventListener('pause', () =>mState());
aud.addEventListener('play', () =>mState());
aud.addEventListener('timeupdate', () => {let prg = aud.currentTime * prog.offsetWidth / aud.duration < 6 ? 6 : aud.currentTime * prog.offsetWidth / aud.duration;prog.style.setProperty('--ww', prg + 'px');audtime.innerText = toMin(aud.currentTime) + ' | ' + toMin(aud.duration);for(j=0; j<lrcAr.length; j++) {if(aud.currentTime >= lrcAr) {cKey = j;if(mKey === j) showLrc(lrcAr);else continue;}}});
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 showLrc = (time) => {let name = mFlag ? 'cover1' : 'cover2';lrc.innerHTML = lrc.dataset.lrc = lrcAr;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','.25'));
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;};
(function mkSpan() {[...Array(10).keys()].forEach((ele,key) => {ele = document.createElement('span');ele.style.cssText += `background: linear-gradient(135deg, #${Math.random().toString(16).substr(-6)}, #${Math.random().toString(16).substr(-6)}); transform: rotate(${key*36}deg) translate(18px)`;btnplay.appendChild(ele);});})();
})();
</script> 不论是歌词还是曲调都是上乘的,太棒了! 欣赏音画佳作! 相约爱晚亭 发表于 2022-10-29 10:36
欣赏音画佳作!
谢谢 醉美水芙蓉 发表于 2022-10-29 11:41
hsla(60,100%,50%,.45),hsla(200,50%,50%,.75))歌词颜色如何设置的?是这个https://www.huachaowang.com/fo ...
hsl 是颜色的另一种表达方式,我那个工具对理解hsl有一定的帮助。主要是理解 hsl 的含义:h,颜色色相,按色盘 0 - 360 度赋值,0和360重合,是红色,120是绿色,240是蓝色,其他颜色在它们之间,有一定规律;s,饱和度,0% - 100% 之间,100%饱和度满,0%是纯灰(即黑);l,亮度,50%是正常亮度,0%没有亮度(黑),100%亮度最大(白)。hsl这样搭配,得到自己所需的颜色。
hsla 是在 hsl 基础上加入 alpha 透明度,a 取值在 0.00 - 1.00 之间,0 为完全透明,1为完全不透明。 梦油 发表于 2022-10-29 10:17
不论是歌词还是曲调都是上乘的,太棒了!
歌词都很精彩 欣赏、点赞 真棒!猫得抓紧学习了,谢谢黑黑 辛苦!{:4_191:} 周末快乐! 这颗尘埃貌似很有想法,歌词有意思{:4_187:} 歌手的嗓音很有特点。黑黑的制作很漂亮,按钮和底图想呼应,歌词色彩也和图图很相配{:4_199:} 马黑黑 发表于 2022-10-29 12:04
歌词都很精彩
是的,黑黑朋友,你有独到的眼光啊。 梦油 发表于 2022-10-29 15:41
是的,黑黑朋友,你有独到的眼光啊。
还行 红影 发表于 2022-10-29 13:39
歌手的嗓音很有特点。黑黑的制作很漂亮,按钮和底图想呼应,歌词色彩也和图图很相配
还行 红影 发表于 2022-10-29 13:38
这颗尘埃貌似很有想法,歌词有意思
有点意思 大猫咪 发表于 2022-10-29 12:55
真棒!猫得抓紧学习了,谢谢黑黑 辛苦! 周末快乐!
{:5_108:} 马黑黑 发表于 2022-10-29 15:47
还行
很漂亮{:4_187:} 马黑黑 发表于 2022-10-29 15:50
有点意思
挺积极的。 红影 发表于 2022-10-29 19:59
挺积极的。
可以的