加林森 发表于 2022-6-12 18:23

《葬花吟 (二胡版伴奏)》- 陈力


<style>
/*帖子外层盒子*/
.mama { position: relative; margin: auto; width: 1000px; height: 600px; background: transparent linear-gradient(to right bottom, darkgreen, snow); box-shadow: 2px 2px 2px #444; }
.mama { left: -202px; width: 1000px; height: 600px; background: lightgreen url('https://pic.imgdb.cn/item/62a559180947543129b2baf1.jpg') no-repeat center / cover; position: relative; box-shadow: 2px 2px 2px #333; }
/*播放器外层盒子*/
.lrcWrap { position: absolute; top: 10px; left: 10px; padding: 20px; width: fit-content; height: fit-content; text-align: center; background: transparent 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; }
/*播放按钮*/
.playbtn { width: 10px; height: 20px; background: #eee; clip-path: polygon(0 0, 0% 100%, 100% 50%); cursor: pointer; }
/*播放按钮鼠标滑过*/
.playbtn:hover { background: red; }
/*暂停按钮*/
.pausebtn { width: 2px; height: 20px; border-style: solid; border-width: 0px 4px; border-color: transparent #eee; display: none; cursor: pointer; }
/*暂停按钮鼠标滑过*/
.pausebtn:hover { border-color: transparent 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: white; }
/*歌词面板外层盒子*/
.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; }
/*歌词ul标签*/
.lrcUl { position: relative; top: 0; margin: 0; padding: 0; }
/*歌词li标签*/
.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>葬花吟 (二胡版伴奏)</p>
                <div class="lrcBox"><ul class="lrcUl"></ul></div>
                <div class="meterWrap">
                        <div class="playbtn"></div>
                        <div class="pausebtn"></div>
                        <div class="meter"><span class="slider"></span></div>
                </div>
      <!-- 播放器结束 -->
      </div>
</div>
<audio class="aud" src="http://www.kumeiwp.com/sub/filestores/2022/06/11/67d61733741e2defd50f76ff4934134a.mp3" autoplay="autoplay" loop="loop"></audio>

<script>
//N多盒子句柄
let aud = document.querySelector('.aud'),
      playbtn = document.querySelector('.playbtn'),
      pausebtn = document.querySelector('.pausebtn'),
      meter = document.querySelector('.meter'),
      slider = document.querySelector('.slider'),
      lrcUl = document.querySelector('.lrcUl');
let slip = 0; //误差修正
//lrc歌词数组
let lrcAr = [
              ['2.05','葬花吟 (二胡版伴奏)-陈力'],
        ['3.45','歌词:曹雪芹'],
        ['4.63','作曲:王力平'],
        ['5.54','演唱:陈力'],
        ['23.07','花谢花飞飞满天'],
        ['33.19','红消香断有谁怜'],
        ['43.81','游丝软系飘春榭'],
        ['56.35','落絮轻沾扑绣帘'],
        ['70.46','一年三百六十日'],
        ['81.14','风刀霜剑严相逼'],
        ['100.91','明媚鲜妍能几时'],
        ['113.99','一朝漂泊难寻觅'],
        ['126.69','花开易见落难寻'],
        ['138.25','阶前愁煞葬花人'],
        ['149.39','独倚花锄偷洒泪'],
        ['161.74','洒上空枝见血痕'],
        ['174.38','愿侬胁下生双翼'],
        ['186.80','随花飞到天尽头'],
        ['199.25','天尽头'],
        ['209.01','何处有香丘'],
        ['217.36','天尽头'],
        ['237.65','何处有香丘'],
        ['244.45','未若锦囊收艳骨'],
        ['255.58','一抔净土掩风流'],
        ['267.72','质本洁来还洁去'],
        ['275.03','强于污淖陷渠沟'],
        ['281.58','尔今死去侬收葬'],
        ['329.34','未卜侬身何日丧'],
        ['339.93','侬今葬花人笑痴'],
        ['346.86','他年葬侬知是谁'],
        ['360.86','天尽头'],
        ['363.61','何处有香丘'],
      ['363.81','一朝春尽红颜老']
];
//将歌词写入li标签
for(j=0; j<lrcAr.length; j++){
      lrcUl.innerHTML += '<li id="li' + lrcAr + '" style="list-style-type: none">' + 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', () => btnstate(1));
aud.addEventListener('play',() => btnstate(0));
//进度条点击事件
meter.onclick = (e) => {
      e = e || event;
      aud.currentTime = (e.clientX - offset(meter,"left")) * aud.duration / meter.clientWidth;
}
//暂停与播放按钮点击事件
pausebtn.onclick = () => { aud.pause(); btnstate(1); }
playbtn.onclick = () => { aud.play(); btnstate(0); }
//获取进度条偏移总量
let 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;
}
//按钮状态
let btnstate = (paused) => {
      paused == 1 ? (playbtn.style.display = 'block', pausebtn.style.display = 'none') : (playbtn.style.display = 'none', pausebtn.style.display = 'block');
}
//初始化按钮状态
aud.paused ? btnstate(1) : btnstate(0);

</script>

加林森 发表于 2022-6-12 18:23

@马黑黑 @小辣椒

加林森 发表于 2022-6-12 18:25

好像还是有点不太同步呢?{:4_203:}

马黑黑 发表于 2022-6-12 18:47

感谢队长的礼物!帖子精美,点赞。

但是,我跟黛玉不熟{:4_170:}

马黑黑 发表于 2022-6-12 18:48

这个背景下,玻璃效果出来了

加林森 发表于 2022-6-12 18:52

马黑黑 发表于 2022-6-12 18:47
感谢队长的礼物!帖子精美,点赞。

但是,我跟黛玉不熟

认识认识就熟悉了嘛。{:4_189:}

加林森 发表于 2022-6-12 18:53

马黑黑 发表于 2022-6-12 18:48
这个背景下,玻璃效果出来了

是的。这个就是你最新版本的。

马黑黑 发表于 2022-6-12 18:59

加林森 发表于 2022-6-12 18:53
是的。这个就是你最新版本的。

测试版本也会有这个效果的,这方面不变

马黑黑 发表于 2022-6-12 18:59

加林森 发表于 2022-6-12 18:52
认识认识就熟悉了嘛。

还是不熟,谈不来的

加林森 发表于 2022-6-12 19:06

马黑黑 发表于 2022-6-12 18:59
测试版本也会有这个效果的,这方面不变

嗯嗯。明白的。

加林森 发表于 2022-6-12 19:07

马黑黑 发表于 2022-6-12 18:59
还是不熟,谈不来的

认识了不就熟悉了嘛。

马黑黑 发表于 2022-6-12 19:08

加林森 发表于 2022-6-12 19:07
认识了不就熟悉了嘛。

认识不了

马黑黑 发表于 2022-6-12 19:08

加林森 发表于 2022-6-12 19:06
嗯嗯。明白的。

{:5_108:}

加林森 发表于 2022-6-12 19:10

马黑黑 发表于 2022-6-12 19:08
认识不了

穿越过去就可以认识的。{:4_172:}

加林森 发表于 2022-6-12 19:11

马黑黑 发表于 2022-6-12 19:08


谢谢老黑啦。{:5_108:}

马黑黑 发表于 2022-6-12 19:17

加林森 发表于 2022-6-12 19:10
穿越过去就可以认识的。

没路费

加林森 发表于 2022-6-12 19:19

马黑黑 发表于 2022-6-12 19:17
没路费

坐你的杀猪刀飞过去不就行啦。{:4_172:}

马黑黑 发表于 2022-6-12 19:24

加林森 发表于 2022-6-12 19:19
坐你的杀猪刀飞过去不就行啦。

抢劫犯法,俺是守法公民

加林森 发表于 2022-6-12 19:48

马黑黑 发表于 2022-6-12 19:24
抢劫犯法,俺是守法公民

又没有喊你去杀人,只是认识一下就行了嘛。

马黑黑 发表于 2022-6-12 20:07

加林森 发表于 2022-6-12 19:48
又没有喊你去杀人,只是认识一下就行了嘛。

没路费
页: [1] 2 3
查看完整版本: 《葬花吟 (二胡版伴奏)》- 陈力