|
|

楼主 |
发表于 2023-4-15 14:52
|
显示全部楼层
<style>
#beijing { margin: 80px 0 0 calc(50% - 593px); width: 1024px; height: 640px; background: lightblue url('https://pic.imgdb.cn/item/6439da6b0d2dde5777a92c6f.jpg') center/cover no-repeat; box-shadow: 3px 3px 20px #000; overflow: hidden; user-select: none; position: relative; }
#mplayer { position: absolute; left: 342px; bottom: 40px; width: fit-content; height: fit-content; display: flex; align-items: center; gap: 8px; z-index: 9; }
#btnwrap { position: relative; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: #ccc linear-gradient(to top right, rgba(255,0,0,.75), rgba(0,255,0,.75)); cursor: pointer; }
#btnwrap:hover { background: #000 linear-gradient(to top right, rgba(255,0,0,.75), rgba(0,255,0,.75)); }
#btnplay { width: 20px; height: 20px; background: #ccc; clip-path: polygon(0 0, 0% 100%, 100% 50%); }
#btnpause { width: 2px; height: 20px; border-style: solid; border-width: 0px 4px; border-color: transparent #eee; display: none; }
#prog { width: 200px; height: 2px; background: #ccc linear-gradient(to right,red,orange,green,tomato) no-repeat; background-size: 1px 2px; cursor: pointer; position: relative; }
#prog::before { position: absolute; content: ''; top: -7px; width: inherit; height: 15px; }
#prog:hover::before { background: rgba(0,200,200,.15); }
#tmsg { font: normal 16px sans-serif; color: #FDFDBD; }
#lrc { position: absolute; left:392px; bottom: 80px; font: bold 1.3em sans-serif; color: #8CB9FB; text-shadow: 1px 1px 2px #000; text-align: center; z-index: 8; }
#lrc:hover, #tmsg:hover { color: snow; }
.txt3d {
position: absolute; left: 692px; top: 180px;
width: 380px;
height: 280px;
line-height: 32px;
font-family: '微软雅黑', '黑体', sans-serif;
font-size: 1.6rem;
color: #8CB9FB;
letter-spacing: 4px;
text-shadow: 1px 1px rgba(206,225,253,0.8),2px 2px rgba(206,225,253,0.7),3px 3px rgba(206,225,253,0.6),4px 4px rgba(206,225,253,0.4);
}
</style>
<div id="beijing">
<div 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></div>
<div id="lrc">lrc歌词</div>
<p class ="txt3d">通体回文TO朝云暮雨<br><br> 云朝梦境意含欣,<br> 雨暮归人玉蕙熏。<br> 文雅隽香生翠韵。<br> 氲氤气运笔耕勤。<br><br> 勤耕笔运气氤氲,<br> 韵翠生香隽雅文。<br> 熏蕙玉人归暮雨,<br> 欣含意境梦朝云。<br>
</div></div>
<script>
let lrcAr = [
['0.00','朝云暮雨(和声版) 中国风组合'],
['280.00','意韵/陈小奇']
];
let aud = new Audio();
aud.src='https://music.163.com/song/media/outer/url?id=1909005235.mp3';
aud.autoplay = true;
aud.loop = true;
btnwrap.onclick = () => aud.paused ? aud.play() : aud.pause();
prog.onclick = (e) => aud.currentTime = aud.duration * e.offsetX / prog.offsetWidth;
aud.addEventListener('pause', () => btnstate());
aud.addEventListener('play',() => btnstate());
aud.addEventListener('timeupdate', () => {
prog.style.backgroundSize = prog.offsetWidth * aud.currentTime / aud.duration + 'px 2px';
tmsg.innerText = toMin(aud.duration) + ' | ' + toMin(aud.currentTime);
for(j=0; j<lrcAr.length; j++) {
if(aud.currentTime >= lrcAr[j][0]) lrc.innerText = lrcAr[j][1];
}
});
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>
|
|