朵拉 发表于 2022-11-19 23:03

西厢寻他 TO:辫子哥哥

本帖最后由 朵拉 于 2022-11-19 23:12 编辑 <br /><br /><style>
#papa { left: -214px; width: 1024px; height: 640px; background: snow url('https://pic.imgdb.cn/item/6378ef4f16f2c2beb1bab4e6.jpg') no-repeat center/cover; display: grid; place-items: center; box-shadow: 3px 3px 20px #000; user-select: none; position: relative; }
#mplayer { position: absolute; bottom: 5px; width: 400px; height: 60px; font: normal 14px sans-serif; }
#mplayer::before, #mplayer::after { position: absolute; width: 100%; height: 50%; color: snow; margin: 15px 0; }
#mplayer::before { content: attr(data-cur); }
#mplayer::after { content: attr(data-dur); text-align: right; }
#btnplay { position: absolute; left: calc(50% - 15px); bottom: 25px; width: 30px; height: 30px; border-radius: 50%; background: conic-gradient(red, magenta, blue, aqua, lime, yellow, red); cursor: pointer; z-index: 2; animation: rot linear 4s infinite; }
#prog { --posX: 0px; position: absolute; bottom: 10px; width: 100%; height: 1px; background: #eee; cursor: pointer; }
#prog::before, #prog::after { position: absolute; content: ''; left: 0; }
#prog::before { width: var(--posX); height: 1px; background: red; }
#prog::after { left: var(--posX); top: calc(50% - 6px); width: 10px; height: 10px; border-radius: 50%; background: pink; }
#lrc { --motion: cover1; --tt: 5s; --state: paused; position: absolute; bottom: 80px; font: bold 2.4em sans-serif; color: hsl(0,10%,90%); -webkit-background-clip: text; filter: drop-shadow(1px 1px 2px hsla(0,100%,0%,.85)); }
#lrc::before { position: absolute; content: attr(data-lrc); width: 20%; height: 100%; color: transparent; overflow: hidden; white-space: nowrap; background: linear-gradient(180deg,hsla(28,15%,50%,.75),hsla(28,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" data-cur="00:00" data-dur="00:00"><span id="prog"></span><span id="btnplay"></span></div>
</div>

<script>
let mKey = 0, mFlag = true, aud = new Audio();
let lrcAr = [,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ];
aud.src = 'https://music.163.com/song/media/outer/url?id=1913206466.mp3';
aud.autoplay = true;
aud.loop = true;
if(aud.paused) btnplay.style.animationPlayState = 'paused';
btnplay.onclick = () => aud.paused ? aud.play() : aud.pause();
mplayer.onmousemove = (e) => { mplayer.style.cursor = e.offsetY > mplayer.offsetHeight / 1.5 ? 'pointer' : 'default'; }
mplayer.onclick =(e) => { if(e.offsetY > mplayer.offsetHeight / 1.5) aud.currentTime = aud.duration * e.offsetX / prog.offsetWidth; }
aud.addEventListener('pause', () => mState());
aud.addEventListener('play', () => mState());
aud.addEventListener('seeked', () => calcKey());
aud.addEventListener('timeupdate', () => { prog.style.setProperty('--posX', prog.offsetWidth * aud.currentTime / aud.duration + 'px'); mplayer.dataset.cur = toMin(aud.currentTime); mplayer.dataset.dur = toMin(aud.duration); for(j=0; j<lrcAr.length; j++) {if(aud.currentTime >= lrcAr) {if(mKey === j) showLrc(lrcAr);else continue;} } });
let mState = () => aud.paused ? (btnplay.style.animationPlayState = 'paused', lrc.style.setProperty('--state', 'paused')) : (btnplay.style.animationPlayState ='running', lrc.style.setProperty('--state', 'running'));
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 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; };
papa.oncontextmenu = () => false;
</script>

朵拉 发表于 2022-11-19 23:13

@辫子哥哥
欢迎辫子哥哥常回家看看,收礼物哈{:4_190:}

朵拉 发表于 2022-11-19 23:14

@马黑黑
马师晚上好,交作业咯,请指正{:4_190:}

红影 发表于 2022-11-19 23:16

歌曲很好听。制作漂亮。欣赏朵宝好帖{:4_187:}

朵拉 发表于 2022-11-19 23:18

红影 发表于 2022-11-19 23:16
歌曲很好听。制作漂亮。欣赏朵宝好帖

谢谢影宝欣赏 周末愉快,么么哒{:4_204:}

辫子哥哥 发表于 2022-11-19 23:26

朵拉 发表于 2022-11-19 23:13
@辫子哥哥
欢迎辫子哥哥常回家看看,收礼物哈

来了来了{:4_187:}

辫子哥哥 发表于 2022-11-19 23:28

红影跑的也太贼快了

辫子哥哥 发表于 2022-11-19 23:29

歌曲很特别,很好听!

辫子哥哥 发表于 2022-11-19 23:30

朵拉 发表于 2022-11-19 23:14
@马黑黑
马师晚上好,交作业咯,请指正

我替黑总批了一一作业完成的非常棒{:4_189:}

辫子哥哥 发表于 2022-11-19 23:31

谢谢小朵拉辛苦了
安了明天见{:4_171:}

马黑黑 发表于 2022-11-19 23:49

朵拉 发表于 2022-11-19 23:14
@马黑黑
马师晚上好,交作业咯,请指正

做的非常好呢,欣赏了

冬天的雨 发表于 2022-11-26 18:43

辫子哥哥 发表于 2022-11-19 23:29
歌曲很特别,很好听!

小子收礼开心{:4_187:}

冬天的雨 发表于 2022-11-26 18:44

欣赏小朵拉美帖{:4_187:}

绿叶清舟 发表于 2022-11-26 19:32

朵拉这个制作漂亮,歌也好听

辫子哥哥 发表于 2022-12-5 13:30

冬天的雨 发表于 2022-11-26 18:43
小子收礼开心

开心开心{:4_170:}
页: [1]
查看完整版本: 西厢寻他 TO:辫子哥哥