这个厉害了,很有眼光呢
还行吧 加林森 发表于 2022-4-19 12:53
又要我抓走哇。
积累起来,准备下一波烤蟹 本帖最后由 加林森 于 2022-6-11 21:53 编辑 <br /><br />马黑黑 发表于 2022-4-19 18:54
积累起来,准备下一波烤蟹
还是吃啊。{:4_189:}
<style>
.mama { position: relative; left: -202px; width: 1000px; height: 600px; background: #ccc url('https://pic.imgdb.cn/item/62a487090947543129e21464.jpg') no-repeat; box-shadow: 2px 2px 2px #444; }
.lrcWrap { position: absolute; right: 10px; top: 10px; padding: 20px; width: fit-content; height: fit-content; text-align: center; background: rgba(20,20,20,.6) linear-gradient(rgba(255,255,255,.25), rgba(255,255,255,.15)); box-shadow: 2px 2px 4px #eee; display: flex; flex-direction: column;align-items: center; }
.meterWrap { position: relative; display: flex; align-items: center; width: fit-content; height: 50px; }
.btn { width: 24px; height: 24px; background: olive; color: #ccc; border: none; font-size: 14px; outline: none; cursor: pointer; }
.btn:hover { color: red; }
.meter { position: relative; width:300px; height: 11px; cursor: pointer; background: linear-gradient(transparent 5px, snow 6px,transparent 0); }
.slider { display: block; position: absolute; width: 4px; height: 100%; background: olive; }
.lrcWrap p { margin: 0 0 12px 0; padding: 0px; color: #ccc; font: normal 1.2em sans-serif; text-shadow: 1px 1px 1px #333; }
.lrcBox { margin: 0; padding: 0; width: 400px; height: 72px;overflow: hidden; user-select: none; position: relative; }
.lrcUl { position: relative; top: 0; margin: 0; padding: 0; }
.lrcUl li { margin: 0; padding: 0; height: 24px; font: normal 18px / 24px sans-serif; color: gray; text-shadow: 1px 1px 1px black; list-style-type: none; }
</style>
<div class="mama">
<div class="lrcWrap">
<p>Audio Player for HTML5</p>
<div class="lrcBox"><ul class="lrcUl"></ul></div>
<div class="meterWrap">
<input class="btn" type="button" value="||" />
<div class="meter"><span class="slider"></span></div>
</div>
</div>
</div>
<audio class="aud" src="https://music.163.com/song/media/outer/url?id=358697.mp3" autoplay="autoplay" loop="loop"></audio>
<script>
let aud = document.querySelector('.aud'),
btn = document.querySelector('.btn');
meter = document.querySelector('.meter'),
slider = document.querySelector('.slider'),
lrcUl = document.querySelector('.lrcUl');
let slip = 0.25;
let lrcAr = [
['0.31','风雨中的美丽 '],
['1.51','歌手:黑鸭子'],
['2.05','所属专辑:超越(精装版)'],
['2.64','想你盼你怨你念你'],
['3.45','天天天天在等你'],
['14.45','想你盼你怨你念你'],
['14.54','wu ho da da da'],
['19.97','一次一次告诉自己'],
['35.82','外面的天空也很美丽'],
['39.29','一次一次鼓舞自己'],
['43.62','去感受雨后空气的清新'],
['44.83','虽然冬雨过后有些冷'],
['51.95','虽然大街上还刮寒风'],
['56.59','一次一次提醒自己'],
['57.84','昨夜的雷声已经远去'],
['66.11','一次一次放纵自己'],
['70.43','让自己投入一切地爱你'],
['75.27','虽然前方的路不清楚'],
['78.84','虽然依然还会有人阻'],
['83.97','我还是想你盼你怨你念你'],
['89.08','天天天天在等你'],
['98.04','我还是想你盼你怨你念你'],
['99.73','天天天天在等你'],
['107.52','一次一次告诉自己'],
['109.26','外面的天空也很美丽'],
['124.67','一次一次鼓舞自己'],
['128.20','去感受雨后空气的清新'],
['132.19','虽然冬雨过后有些冷'],
['136.23','虽然大街上还刮寒风'],
['141.39','一次一次提醒自己'],
['146.25','昨夜的雷声已经远去'],
['153.91','一次一次放纵自己'],
['157.17','让自己投入一切地爱你'],
['163.04','虽然前方的路不清楚'],
['168.20','虽然依然还会有人阻'],
['171.61','我还是想你盼你怨你念你'],
['176.99','天天天天在等你'],
['185.73','我还是想你盼你怨你念你'],
['187.68','天天天天在等你'],
['194.18','我还是想你盼你怨你念你']
['220.30','嘿 呀伊嘿 呀伊嘿 嘿'],
['223.30','嘿 呀伊嘿 呀伊嘿 嘿']
];
for(j=0; j<lrcAr.length; j++){
lrcUl.innerHTML += '<li id="li' + lrcAr + '">' + lrcAr + '</li>';
}
aud.addEventListener('timeupdate', () => {
let prog = (meter.clientWidth - slider.clientWidth) * aud.currentTime / aud.duration;
slider.style.transform = 'translate(' + prog + 'px)';
let tt = aud.currentTime;
for(j=0; j<lrcAr.length; j++){
if(tt >= lrcAr - slip){
if(j > 0){
let idxLast = lrcAr;
document.getElementById('li' + idxLast).style.color = 'gray';
lrcUl.style.top = '-' + (j * 24 - 24) + 'px';
}
let idx = lrcAr;
document.getElementById('li' + idx).style.color = 'ghostwhite';
}
}
})
aud.addEventListener('ended', () => {
document.getElementById("li" + lrcAr).style.color = 'gray';
lrcUl.style.top = 0;
});
aud.addEventListener('pause', () => btn.value = '▷');
aud.addEventListener('play',() => btn.value = '||');
meter.onclick = (e) => {
e = e || event;
aud.currentTime = (e.clientX - offset(meter,"left")) * aud.duration / meter.clientWidth;
}
btn.onclick = () => aud.paused ? (aud.play(),btn.value = '||') : (aud.pause(),btn.value = '▷');
function offset(obj,direction){//位移量
let offsetDir = "offset" + direction.toUpperCase()+direction.substring(1);
let realNum = obj;
let positionParent = obj.offsetParent;
while(positionParent != null){
realNum += positionParent;
positionParent = positionParent.offsetParent;
}
return realNum;
}
btn.value = aud.paused ? '▷' : '||';
</script>
女子十二乐坊,有段时间很出名的,好像现在见得少了,队长好制作,欣赏美帖!
{:4_204:}{:4_199:} 加林森 发表于 2022-4-19 19:12
还是吃啊。
必须的 大猫咪 发表于 2022-4-19 20:05
女子十二乐坊,有段时间很出名的,好像现在见得少了,队长好制作,欣赏美帖!
猫猫晚上好。是的,现在不知道怎么样了?{:4_204:}{:4_190:} 马黑黑 发表于 2022-4-19 20:57
必须的
标准吃货{:4_189:} 加林森 发表于 2022-4-19 21:17
标准吃货
那是那是 马黑黑 发表于 2022-4-19 22:14
那是那是
佩服佩服
页:
1
[2]