|
|

楼主 |
发表于 2022-10-14 07:33
|
显示全部楼层
本帖演示:纯音乐或不需要歌词同步的音画帖使用线条+小光盘播放控制器
- <style>
- #papa { left: -214px; width: 1024px; height: 640px; background: snow url('https://638183.freep.cn/638183/t22/webp/robot.webp') no-repeat center/cover; display: grid; place-items: center; box-shadow: 3px 3px 20px #000; user-select: none; position: relative; }
- #mplayer { position: absolute; top: 20px; left: 10px; 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: 3px; height: 10px; background: silver; }
- #tit { position: absolute; bottom: 20px; right: 30px; font: bold 3em sans-serif; color: snow; text-shadow: 2px 2px 3px #212121; }
- @keyframes rot { to { transform: rotate(1turn); } }
- </style>
- <div id="papa">
- <div id="tit">机<br>器<br>人</div>
- <div id="mplayer" data-cur="00:00" data-dur="00:00"><span id="prog"></span><span id="btnplay"></span></div>
- </div>
- <script>
- let aud = new Audio();
- aud.src = 'https://music.163.com/song/media/outer/url?id=1456419002.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', () => aud.play());
- 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);});
- let mState = () => btnplay.style.animationPlayState = aud.paused ? 'paused' : 'running';
- 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>
复制代码
|
评分
-
| 参与人数 2 | 威望 +100 |
金钱 +200 |
经验 +100 |
收起
理由
|
小辣椒
| + 50 |
+ 100 |
+ 50 |
很给力! |
红影
| + 50 |
+ 100 |
+ 50 |
赞一个! |
查看全部评分
|