加林森 发表于 2022-7-30 00:19

本帖最后由 加林森 于 2022-9-14 19:52 编辑 <br /><br />红影 发表于 2022-7-29 23:57
找图完全是自己的功夫,这个倒是没法学的呢
是的。

<style>
#papa { left: -402px; width: 1400px; height: 786px; top: 150px; background: darkred url('https://pic.imgdb.cn/item/6321c06316f2c2beb1ed5b52.jpg') no-repeat center/cover; display: grid; place-items: center; box-shadow: 3px 3px 20px #000; user-select: none; position: relative; z-index: 1;}
#mplayer { position: absolute; bottom:80px; } /* 播放器svg */
#lrc { position: absolute; left: 420px; top: 450px; display: block; } /* 歌词svg */
#lrctxt { dominant-baseline: middle; font: bold 2.6em sans-serif; letter-spacing: 3px; }
#tmsg { fill: #ccc; font: normal 1em sans-serif; dominant-baseline: middle; }
#btnwrap { fill: #ccc; cursor: pointer; }
#btnwrap:hover { fill: orange; }

#d1{ position: absolute; width: 66px; height: 113px; top: 60px; left: 1300px;opacity: 0.45; }
#d2{ position: absolute; width: 66px; height: 113px; top: 60px; left: 580px;opacity: 0.45; }
#d3{ position: absolute; width: 66px; height: 113px; top: 60px; left: 80px;opacity: 0.35; }
#zm{ position: absolute; width: 250px; height: 44px; top: 360px; left:10 80px;opacity: 0.95; }

</style>

<div id="papa">

<img id="d1" src="https://wj.zp68.com/lxx/yunhua/2022/09/14/ltws.gif" alt="" />
<img id="d2" src="https://wj.zp68.com/lxx/yunhua/2022/09/14/ltws.gif" alt="" />
<img id="d3" src="https://wj.zp68.com/lxx/yunhua/2022/09/14/ltws.gif" alt="" />
<img id="zm" src="https://wj.zp68.com/lxx/yunhua/2022/09/14/zm.gif" alt="" />

      <!-- 播放器 -->
      <svg id="mplayer" width="750" height="80" shape-rendering="geometricPrecision">
                <circle cx="30" cy="30" r="20" fill="none" stroke="url(#gradient)" stroke-width="3" />
                <g id="mama" style="cursor: pointer">
                        <line x1="60" y1="30" x2="490" y2="30" stroke="transparent" stroke-width="20" />
                        <line id="track" x1="60" y1="30" x2="490" y2="30" stroke="snow" shape-rendering="crispEdges" />
                        <line id="prog" x1="60" y1="30" x2="490" y2="30" stroke="red" shape-rendering="crispEdges" />
                </g>
                <text id="tmsg" x="500" y="30">00:00 | 00:00</text>
                <g id="btnwrap">
                        <path id="btnplay" d="M 22 20,22 40,42 30 z"></path>
                        <path d="M 29 20, 29 40, 32 40, 32 20, 29 20 z" fill="transparent"></path>
                        <path id="btnpause" d="M 24 20,24 40,29 40,29 20,24 20 z M 32 20,32 40,37 40,37 20,32 20 z" style="display: none"></path>
                </g>
      </svg>
      <!-- lrc歌词 -->
      <svg id="lrc" width="760" height="160">
                <defs>
                        <linearGradient id="gradient" x1="0" y1="0" x2="1" y2="1">
                              <stop offset="0%" stop-color="green"/>
                              <stop offset="50%" stop-color="snow"/>
                              <stop offset="100%" stop-color="gold"/>
                        </linearGradient>
                </defs>
                <text id="lrctxt" x="10" y="30" fill="transparent" stroke="url(#gradient)" shape-rendering="crispEdges">遇见 - 邓园长</text>
      </svg>
</div>

<script>
let lrcAr = [
               ['00.00','遇见 - 邓园长'],
        ['25.61','听见 冬天的离开'],
        ['30.74','我在某年某月 醒过来'],
        ['35.65','我想 我等 我期待'],
        ['40.79','未来却不能因此安排'],
        ['59.28','阴天 傍晚 车窗外'],
        ['64.61','未来有一个人在等待'],
        ['69.58','向左向右向前看'],
        ['74.78','爱要拐几个弯才来'],
        ['79.74','我遇见谁 会有怎样的对白'],
        ['85.03','我等的人 他在多远的未来'],
        ['89.89','我听见风来自地铁和人海'],
        ['95.09','我排着队 拿着爱的号码牌'],
        ['121.27','阴天 傍晚 车窗外'],
        ['126.45','未来有一个人在等待'],
        ['131.49','向左向右向前看'],
        ['136.72','爱要拐几个弯才来'],
        ['141.67','我遇见谁 会有怎样的对白'],
        ['146.81','我等的人 他在多远的未来'],
        ['151.96','我听见风来自地铁和人海'],
        ['157.04','我排着队 拿着爱的号码牌'],
        ['172.69','我往前飞 飞过一片时间海'],
        ['177.77','我们也曾在爱情里受伤害'],
        ['183.00','我看着路 梦的入口有点窄'],
        ['187.74','我遇见你是最美丽的意外'],
        ['193.52','总有一天 我的谜底会揭开']
];
let cc = {
      x: 1*track.getAttribute('x1'),
      len: track.getTotalLength(),
};
let aud = new Audio();
aud.src = 'https://music.163.com/song/media/outer/url?id=1475319299.mp3';
aud.autoplay = true;
aud.loop = true;
prog.style.strokeDasharray = prog.style.strokeDashoffset = cc.len;

btnwrap.onclick = () => aud.paused ? aud.play() : aud.pause();
mama.onclick = (e) => aud.currentTime = aud.duration * (e.offsetX - cc.x) / cc.len;
aud.addEventListener('pause', () => btnstate());
aud.addEventListener('play',() => btnstate());
aud.addEventListener('timeupdate', () => {
      prog.style.strokeDashoffset = cc.len - cc.len * aud.currentTime / aud.duration + 'px';
      tmsg.textContent = toMin(aud.currentTime) + " | " + toMin(aud.duration);
      for(j=0; j<lrcAr.length; j++) {
                if(aud.currentTime >= lrcAr) lrctxt.textContent = lrcAr;
      }
});

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>
<br><br><br><br><br><br><br><br><br><br>

樵歌 发表于 2022-7-30 06:42

加林森 发表于 2022-7-29 21:31
就是玩玩。

早上好,出门走路{:4_190:}

加林森 发表于 2022-7-30 07:46

樵歌 发表于 2022-7-30 06:42
早上好,出门走路

好的。

樵歌 发表于 2022-7-30 19:38

加林森 发表于 2022-7-29 21:31
就是玩玩。

越玩越溜。

加林森 发表于 2022-7-30 19:45

樵歌 发表于 2022-7-30 19:38
越玩越溜。

是的。就是想玩点花样出来。

樵歌 发表于 2022-7-30 19:56

加林森 发表于 2022-7-30 19:45
是的。就是想玩点花样出来。

已经很花了{:4_189:}

加林森 发表于 2022-7-30 20:56

樵歌 发表于 2022-7-30 19:56
已经很花了

{:4_172:}

小辣椒 发表于 2022-7-30 21:25

队长复习前面的播放器,很用功好学生的{:4_199:}

加林森 发表于 2022-7-30 21:39

小辣椒 发表于 2022-7-30 21:25
队长复习前面的播放器,很用功好学生的

谢谢啦!{:4_190:}
页: 1 [2]
查看完整版本: 《苍天在上》- 郑钧