吉他手(学习老黑“大王叫我来巡山”制作)
<style>
#papa { left: -214px; width: 1024px; height: 512px; background: gray url('https://pic.imgdb.cn/item/6310449216f2c2beb134f05b.jpg') no-repeat center/cover; box-shadow: 3px 3px 20px #000; overflow: hidden; user-select: none; position: relative; }
#lrc { position: absolute; left: 630px; top: 40px; font: bold 1.5em sans-serif; color: #FF69B4; text-shadow: 1px 1px 2px #000; letter-spacing: 2px; }
#mplayer { position: absolute; left: 630px; top: 80px; width: fit-content; height: fit-content; display: flex; align-items: center; gap: 8px; }
#btnwrap { width: 28px; height: 28px; background: #9AB38B; border-radius: 50%; display: grid; place-items: center; cursor: pointer; }
#btnwrap:hover { background: #FF69B4; }
#btnplay { width: 16px; height: 16px; background: gold; clip-path: polygon(0 0, 0% 100%, 100% 50%); }
#btnpause { width: 2px; height: 20px; border-style: solid; border-width: 0px 4px; border-color: transparent gold; display: none; }
#prog { width: 200px; height: 2px; background: #FF69B4 linear-gradient(90deg,red,olive,red) no-repeat ; background-size: 1px 2px; position: relative; cursor: pointer; }
#prog::before { position: absolute; top: -5px; height: 12px; width: 200px; content: ''; }
#tmsg { left: 260px; bottom: 16px; color: #FF69B4; }
.ball { position: absolute; left: -10px; top: 0; width: 10px; height: 10px; border-radius: 50%; background: red; animation: move 40s var(--ss) linear infinite; }
@keyframes move {
0%, 100% { left: 0; top: 0; }
25% { left: calc(100% - 10px); top: 0; }
50% { left: calc(100% - 10px); top: calc(100% - 10px); }
75% { left: 0; top: calc(100% - 10px); }
}
</style>
<div id="papa">
<span id="lrc">lrc歌词</span>
<span id="mplayer">
<span id="btnwrap"><span id="btnplay"></span><span id="btnpause"></span></span>
<span id="prog"></span>
<span id="tmsg">00:00 | 00:00</span>
</span>
</div>
<script>
let lrcAr = [
['00.00','吉他手-陈绮贞'],
['3.42','今天该穿什么才好'],
['5.59','机会难得别迟到'],
['7.63','我还没有心理准备'],
['9.69','所以我轻松跳舞'],
['13.15','见了面该说什么才好'],
['15.53','机会难得别胆小'],
['17.69','我还没有心理准备'],
['19.71','让自己不同凡响'],
['23.37','为了他我用力尖叫'],
['25.69','为了他我用力跳'],
['27.82','不在乎他们和我一样贪恋你的微笑'],
['33.32','为了他我往前冲吧'],
['35.71','在多的人也不怕'],
['38.00','我最爱的吉他手今天和我 视线交错'],
['40.78','短短一秒钟 就算是短短一秒钟'],
['47.24','就像是握住他的手'],
['49.74','就像是亲口对他说'],
['52.24','因为那短短一秒钟'],
['55.03','就算是短短一秒钟'],
['60.09','我像是握住他的手'],
['62.16','就像是亲口对他说'],
['63.26','我爱你 我爱你'],
['68.28','我用尽所有美好梦想'],
['73.06','就算和别人享有'],
['75.11','你精彩的假动作'],
['89.19','为了他我用力尖叫'],
['91.30','为了他我用力跳'],
['93.46','不在乎他们和我一样贪恋你的微笑'],
['98.90','为了他我往前冲吧'],
['101.26','在多的人也不怕'],
['103.54','我最爱的吉他手今天和我 视线交错'],
['108.93','短短一秒钟 就算是短短一秒钟'],
['112.80','就像是握住他的手'],
['115.40','就像是亲口对他说'],
['117.94','因为那短短一秒钟'],
['120.51','就算是短短一秒钟'],
['123.08','我像是握住他的手'],
['125.66','就像是亲口对他说'],
['128.88','我爱你 我爱你'],
['133.63','我用尽所有美好梦想'],
['138.60','就算和别人享有'],
['140.71','你精彩的假动作'],
['148.95','我爱你 我爱你'],
['153.81','我用尽所有美好梦想'],
['158.79','就算和别人享有'],
['160.90','你精彩的假动作'],
['169.14','不想和别人相拥'],
['171.08','你每一个小动作']
];
let aud = new Audio(), lw = prog.offsetWidth;
aud.src = 'https://music.163.com/song/media/outer/url?id=5239091.mp3';
aud.autoplay = true;
aud.loop = true;
Array.from({length: 60}).forEach((item,key) => {
item = document.createElement('span');
item.className = 'ball';
item.style.cssText = `--ss: ${key * 0.5}s; background: #${Math.random().toString(16).substr(-6)};`;
papa.appendChild(item);
});
prog.onclick = (e) => aud.currentTime = aud.duration * e.offsetX / prog.offsetWidth;
btnwrap.onclick = () => aud.paused ? aud.play() : aud.pause();
aud.addEventListener('playing', ()=> btnstate());
aud.addEventListener('pause', ()=> btnstate());
aud.addEventListener('timeupdate', () => {
prog.style.backgroundSize = lw * aud.currentTime / aud.duration + 'px 2px';
tmsg.innerText = toMin(aud.currentTime) + ' | ' + toMin(aud.duration);
for(j = 0; j < lrcAr.length;j ++) {
if(aud.currentTime >= lrcAr) lrc.innerText = lrcAr;
}
});
let btnstate = () => aud.paused ? (btnplay.style.display = 'block', btnpause.style.display = 'none') : (btnplay.style.display = 'none', btnpause.style.display = 'block');
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>
@马黑黑学习制作了一个。 你的彩球也转上啦!你学的真快。
{:4_199:} 梦油 发表于 2022-9-1 18:02
你的彩球也转上啦!你学的真快。
跟到学没错的。{:4_189:} 欣赏队长大作 马黑黑 发表于 2022-9-1 18:12
欣赏队长大作
我调整了播放器位子,改变了歌词的颜色。另外的名义敢动。 加林森 发表于 2022-9-1 18:15
我调整了播放器位子,改变了歌词的颜色。另外的名义敢动。
慢慢来,就能了解各处代码的作用,能灵活使用代码的能力就会存在。 马黑黑 发表于 2022-9-1 18:16
慢慢来,就能了解各处代码的作用,能灵活使用代码的能力就会存在。
嗯嗯。好的好的。 队长这么快就做出来,真好。制作漂亮,欣赏队长好帖{:4_187:} 加林森 发表于 2022-9-1 18:09
跟到学没错的。
你真聪明,学的也真快。 红影 发表于 2022-9-1 19:39
队长这么快就做出来,真好。制作漂亮,欣赏队长好帖
嗯嗯。做出来了。 梦油 发表于 2022-9-1 20:11
你真聪明,学的也真快。
我还得继续努力呢。 @小辣椒 本帖最后由 加林森 于 2022-9-1 20:57 编辑
什么网络?还打联发的?晕~~~~~~~~~~~ 醉美水芙蓉 发表于 2022-9-1 21:15
欣赏队长佳作!
谢谢水芙蓉支持!{:4_190:} 加林森 发表于 2022-9-1 20:13
嗯嗯。做出来了。
这些小珠珠真漂亮{:4_187:} 红影 发表于 2022-9-1 21:51
这些小珠珠真漂亮
是啊。给帖子了活跃性。 加林森 发表于 2022-9-1 17:07
@马黑黑学习制作了一个。
队长你这个按钮颜色修改了,非常棒 小辣椒 发表于 2022-9-1 22:08
队长你这个按钮颜色修改了,非常棒
可以暂停的啊。
页:
[1]
2