|
|

楼主 |
发表于 2022-7-14 07:07
|
显示全部楼层
代码:
- <style>
- #papa { left: -214px; width: 1024px; height: 640px; box-shadow: 4px 4px 30px #000; border-radius: 6px; overflow: hidden; position: relative; }
- #mama {position: absolute; width: inherit; height: inherit; left: 0; top: -640px; background: #ccc url('https://638183.freep.cn/638183/t22/hl/kong.jpg') no-repeat center / cover; }
- #mama input { border: none; outline: none; opacity: .75; cursor: pointer; }
- #mama p { margin: 0; padding: 0; }
- .playbox { position: absolute; left: 10px; top: 10px; padding: 10px; font: normal 1em sans-serif; color: #eee; background: rgba(255,255,255,.2); border-radius: 8px; backdrop-filter: blur(1px); overflow: hidden; box-shadow: 1px 1px 2px rgba(0,0,0,.15); z-index: 100; }
- #btnplay { width: 30px; height: 30px; border-radius: 50%; }
- #btnplay:hover { background: #aaa; color: #ff0000; }
- #papa > img { position: absolute; border: none; outline: none; }
- #ufo2 { left: 0; top: 0; width: 64px; height: 80px; transition: all 2s; }
- #tang1 { top: 520px; width: 120px; height: 120px; opacity: .2; cursor: pointer; }
- @keyframes up { to { transform: translateY(-700px); } }
- @keyframes down { to { top: 0px; } }
- </style>
- <div id="papa">
- <img id="ufo2" src="https://638183.freep.cn/638183/t22/hl/ufo2.gif" alt="" />
- <img id="tang1" src="https://638183.freep.cn/638183/t22/hl/tang1.gif" alt="" />
- <div id="mama">
- <div class="playbox">
- <p id="geci" style="font-size: 1.2em; text-shadow: 1px 1px 1px #222">stand by ... </p>
- <p style="display: flex; align-items: center; gap: 4px; margin-top: 10px;">
- <input id="btnplay" type="button" value=">" />
- <input id="slider" type="range" min="0" max="100" value="0" />
- <span id="per">0%</span>
- </p>
- </div>
- </div>
- </div>
- <audio id="aud" src="https://music.163.com/song/media/outer/url?id=442488.mp3" loop="loop"></audio>
- <script>
- let lrcAr = [ ['0.00','纯音乐 - 空中散步'], ['120.00','没有音乐人生将与精彩无缘'] ];
- let num = (min, max) => Math.floor(Math.random() * (max-min+1)) + min;
- tang1.style.left = num(0,924) + 'px';
- ufo2.style.left = num(0,924) + 'px';
- tang1.onclick = () => {
- tang1.style.opacity = 1;
- ufo2.style.left = tang1.offsetLeft + 30 + 'px';
- ufo2.style.top = tang1.offsetTop - 60 + 'px';
- setTimeout(() => {
- ufo2.style.animation = tang1.style.animation = 'up 4s forwards';
- },2200);
- setTimeout(() => {
- mama.style.animation = 'down 4s forwards';
- aud.play();
- },4300);
- }
- slider.onmousedown = () => aud.pause();
- slider.onchange = () => { aud.currentTime = slider.value * aud.duration / 100; aud.play(); }
- btnplay.onclick = () => aud.paused ? aud.play() : aud.pause();
- aud.addEventListener('playing', () => btnplay.value = '||');
- aud.addEventListener('pause', () => btnplay.value = '>');
- aud.addEventListener('timeupdate', () => {
- let prog = 100 * aud.currentTime / aud.duration;
- slider.value = prog;
- per.innerText = toMin(aud.currentTime) + ' | ' + toMin(aud.duration);
- for(j=0; j<lrcAr.length; j++){
- if(aud.currentTime >= lrcAr[j][0]) geci.innerHTML = lrcAr[j][1];
- }
- });
- let toMin = (val) => {
- if(!val) return '0:0';
- val = Math.floor(val);
- return parseInt(val / 60) + ':' + parseFloat(val % 60);
- }
- </script>
复制代码
|
|