马黑黑 发表于 2022-10-26 07:23

<style>
#papa { left: -214px; width: 1024px; height: 640px; background: url('https://638183.freep.cn/638183/t22/webp/goose.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; }
#papa::before { position: absolute; content: url('https://638183.freep.cn/638183/t22/gif/girl.gif'); width: 160px; height: 60px; mix-blend-mode: multiply; }
#mplayer { position: absolute; bottom: 10px; display: grid; grid-template-columns: auto auto auto; place-items: center; gap: 6px; user-select: none; }
#btnplay {border-radius: 50%; width: 50px; height: 50px; cursor: pointer; animation: rot linear 3s infinite; }
#prog { --ww: 0px; width: 300px; height: 12px; border: 1px solid green; 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, orange, red); opacity: .65; }
#audtime { font: normal 14px sans-serif; color: hsl(0,80%,50%); }
#lrc { --motion: cover1; --tt: 5s; --state: paused; position: absolute; bottom: 60px; 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,50%,50%,.45),hsla(0,100%,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">
                <img id="btnplay" src="https://638183.freep.cn/638183/t22/btn/g1.png" alt="" />
                <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=1930158632.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;}
})();
</script>

马黑黑 发表于 2022-10-26 07:24

代码
<style>
#papa { margin: auto; width: 1024px; height: 640px; background: url('https://638183.freep.cn/638183/t22/webp/goose.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; }
#papa::before { position: absolute; content: url('https://638183.freep.cn/638183/t22/gif/girl.gif'); width: 160px; height: 60px; mix-blend-mode: multiply; }
#mplayer { position: absolute; bottom: 10px; display: grid; grid-template-columns: auto auto auto; place-items: center; gap: 6px; user-select: none; }
#btnplay {border-radius: 50%; width: 50px; height: 50px; cursor: pointer; animation: rot linear 3s infinite; }
#prog { --ww: 0px; width: 300px; height: 12px; border: 1px solid green; 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, orange, red); opacity: .65; }
#audtime { font: normal 14px sans-serif; color: hsl(0,80%,50%); }
#lrc { --motion: cover1; --tt: 5s; --state: paused; position: absolute; bottom: 60px; 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,50%,50%,.45),hsla(0,100%,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">
                <img id="btnplay" src="https://638183.freep.cn/638183/t22/btn/g1.png" alt="" />
                <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=1930158632.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;}
})();
</script>

马黑黑 发表于 2022-10-26 07:25

播放控制器按钮是图片,img标签

闲言不语 发表于 2022-10-26 09:19

好大好肥的白鹅,现在价格老高了。{:4_199:}

相约爱晚亭 发表于 2022-10-26 09:58

欣赏音画佳作!

梦油 发表于 2022-10-26 10:08

歌曲真好听。

醉美水芙蓉 发表于 2022-10-26 11:46

马黑黑 发表于 2022-10-26 12:09

醉美水芙蓉 发表于 2022-10-26 11:46
好可爱的小孩子!欣赏黑黑老师新帖!

小女孩是很可爱的

马黑黑 发表于 2022-10-26 12:09

闲言不语 发表于 2022-10-26 09:19
好大好肥的白鹅,现在价格老高了。

这是观赏鹅,别打歪主意{:4_170:}

马黑黑 发表于 2022-10-26 12:09

梦油 发表于 2022-10-26 10:08
歌曲真好听。

清新,青春

马黑黑 发表于 2022-10-26 12:10

相约爱晚亭 发表于 2022-10-26 09:58
欣赏音画佳作!

{:4_180:}

梦油 发表于 2022-10-26 13:07

马黑黑 发表于 2022-10-26 12:09
清新,青春

是的,黑黑朋友。这支歌曲的曲调也很动听。

红影 发表于 2022-10-26 14:58

这么大一只鹅,看着还挺萌的{:4_173:}

红影 发表于 2022-10-26 14:58

那个按钮图片本来就是圆的,为什么还要加border-radius: 50%; ?

红影 发表于 2022-10-26 15:00

这图片按钮和特殊符号按钮还挺像的呢,不说明都分辨不出来{:4_173:}

小辣椒 发表于 2022-10-26 18:04

黑黑这个背景颜色和播放器配的特别好{:4_178:}

小辣椒 发表于 2022-10-26 18:06

这个播放器按钮是图片格式可以自己替换了,黑黑又出新花样了,特别厉害{:4_178:}

马黑黑 发表于 2022-10-26 20:32

小辣椒 发表于 2022-10-26 18:06
这个播放器按钮是图片格式可以自己替换了,黑黑又出新花样了,特别厉害

原来的换图片是个简单的是啊

马黑黑 发表于 2022-10-26 20:35

梦油 发表于 2022-10-26 13:07
是的,黑黑朋友。这支歌曲的曲调也很动听。

还不错的

马黑黑 发表于 2022-10-26 20:36

小辣椒 发表于 2022-10-26 18:04
黑黑这个背景颜色和播放器配的特别好

还行
页: [1] 2 3 4 5
查看完整版本: