小辣椒 发表于 2022-10-21 20:37

月光小夜曲(学习黑黑何者般若播放器)


<style>
#papa { margin: auto; left: -340px; width: 1280px;top:150px; height: 700px; background: url('https://wj.zp68.com/lxx/yunhua/2022/05/30/yu.gif') no-repeat center/cover; box-shadow: 3px 3px 20px #000; position: relative; display: grid; place-items: center; user-select: none; z-index: 1; --opt: .15;}
#papa::before { position: absolute; content:}
#mplayer { position: absolute; bottom: 20px; display: grid; grid-template-columns: auto auto; place-items: center; z-index: 9; }
#btnplay { width: 35px; height: 35px; border-radius: 50%; background: tan linear-gradient(hsla(240,100%,50%,.75), hsla(0,100%,50%,.6)); cursor: pointer; animation: rot linear 3s infinite; }
#lrc { --motion: cover1; --tt: 5s; --state: paused; position: absolute; bottom: 60px; font: bold 2.2em sans-serif; color: hsl(0,10%,90%); -webkit-background-clip: text; filter: drop-shadow(1px 1px 2px hsla(0,100%,0%,.85)); }
#lrc::before { position: absolute; content: attr(data-lrc); width: 20%; height: 100%; color: transparent; overflow: hidden; white-space: nowrap; background: linear-gradient(180deg,hsla(240,30%,50%,.65),hsla(240,30%,50%,.65)); filter: inherit; -webkit-background-clip: text; animation: var(--motion) var(--tt) linear forwards; animation-play-state: var(--state); }
#tjia { position: absolute;content: ''; width: 72px; height: 102px; left: 602px; ;top:450px; opacity: .5; }

@keyframes cover1 { from { width: 0; } to { width: 100%; } }
@keyframes cover2 { from { width: 0; } to { width: 100%; } }
@keyframes rot { to { transform: rotate(1turn); } }
</style>

<div id="papa">

      <img id="tjia" src="https://wj.zp68.com/lxx/yunhua/2022/10/02/gnyu.jpg" alt="" />
      <div id="lrc" data-lrc="花潮lrc在线">花潮lrc在线</div>
      <div id="mplayer">
                <span id="btnplay"></span>
                <svg id="iplay" width="500" height="12">
                        <line id="track" x1="5" y1="5" x2="390" y2="5" stroke="hsla(60,40%,80%,0.5)" stroke-width="5" stroke-linecap="round" />
                        <line id="prog" x1="5" y1="5" x2="390" y2="5" stroke="hsla(0,100%,50%,0.5)" stroke-width="5" stroke-dasharray="390" stroke-dashoffset="390" stroke-linecap="round" />
                        <text id="audtime" x="400" y="12" font-size="14" fill="hsl(0,0%,100%)">00:00 | 00:00</text>
                </svg>
      </div>
</div>

<script>
(function() {
      let len = track.getTotalLength(), aud = new Audio(), mKey = 0, mFlag = true;
      aud.src = 'https://wj1.zp68.com:812/lxx/yunhua/2022/01/01/03.mp3';
      let lrcAr = [
                ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ];
      aud.loop = true;
      aud.autoplay = true;
      btnplay.style.animationPlayState = aud.paused ? 'paused' : 'running';
      btnplay.onclick = () => aud.paused ? aud.play() : aud.pause();
      aud.addEventListener('seeked', () => calcKey());
      prog.onclick = track.onclick = (e) => aud.currentTime = aud.duration * (e.offsetX - 10) / len;
      aud.addEventListener('pause', () =>mState());
      aud.addEventListener('play', () =>mState());
      aud.addEventListener('timeupdate', () => {prog.style.strokeDashoffset = len - aud.currentTime * len / aud.duration;audtime.textContent = toMin(aud.currentTime) + ' | ' + toMin(aud.duration);for(j=0; j<lrcAr.length; j++) {if(aud.currentTime >= lrcAr) {cKey = j;if(mKey === j) showLrc(lrcAr);else continue;}}});
      let calcKey = () => {for(j = 0; j < lrcAr.length; j ++) {if(aud.currentTime <= lrcAr) {mKey = j - 1;break;}}if(mKey <0) mKey = 0;if(mKey > lrcAr.length - 1) mKey = lrcAr.length - 1;let time = lrcAr - (aud.currentTime - lrcAr);showLrc(time);};
      let showLrc = (time) => {let name = mFlag ? 'cover1' : 'cover2';lrc.innerHTML = lrc.dataset.lrc = lrcAr;lrc.style.setProperty('--motion', name);lrc.style.setProperty('--tt', time + 's');lrc.style.setProperty('--state', 'running');mKey += 1;mFlag = !mFlag;};
      let mState = () => aud.paused ? (btnplay.style.animationPlayState = 'paused',lrc.style.setProperty('--state', 'paused'),papa.style.setProperty('--opt','0')) : (btnplay.style.animationPlayState = 'running', lrc.style.setProperty('--state', 'running'),papa.style.setProperty('--opt','.15'));
      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-10-21 20:38

@马黑黑

黑黑捣鼓一个,这个播放器我喜欢的{:4_189:}

小辣椒 发表于 2022-10-21 20:38

用了黑黑的小鱼儿图图{:4_189:}谢谢黑黑,用了2次了{:4_170:}

马黑黑 发表于 2022-10-21 20:40

动感十足,美丽异常{:4_178:}

小辣椒 发表于 2022-10-21 20:42

马黑黑 发表于 2022-10-21 20:40
动感十足,美丽异常

黑黑,这个播放器我加长了滚动条,感觉现在的图图应该稍微加长一点漂亮

小辣椒 发表于 2022-10-21 20:43

这首歌我太熟了,歌词同步一次速成

醉美水芙蓉 发表于 2022-10-21 20:50

小辣椒 发表于 2022-10-21 21:05

醉美水芙蓉 发表于 2022-10-21 20:50
欣赏辣椒美女漂亮播放器!

谢谢水芙蓉欣赏~~{:4_171:}

马黑黑 发表于 2022-10-21 21:10

小辣椒 发表于 2022-10-21 20:42
黑黑,这个播放器我加长了滚动条,感觉现在的图图应该稍微加长一点漂亮

对,要根据情景调整,协调才美

相约爱晚亭 发表于 2022-10-21 21:28

欣赏精美音画佳作!

小辣椒 发表于 2022-10-21 21:32

马黑黑 发表于 2022-10-21 21:10
对,要根据情景调整,协调才美

现在在做那个黄的播放器,不加歌词同步可以快一点做出来

小辣椒 发表于 2022-10-21 21:33

相约爱晚亭 发表于 2022-10-21 21:28
欣赏精美音画佳作!

谢谢爱晚亭欣赏{:4_187:}

马黑黑 发表于 2022-10-21 21:39

小辣椒 发表于 2022-10-21 21:32
现在在做那个黄的播放器,不加歌词同步可以快一点做出来

明天我给它加歌词同步

小辣椒 发表于 2022-10-21 21:50

马黑黑 发表于 2022-10-21 21:39
明天我给它加歌词同步

黑黑我这个没有歌词同步的做好了,那今天不发,明天加歌词同步再发

马黑黑 发表于 2022-10-21 21:50

#tjia { position: absolute;content: ''; width: 72px; height: 102px; left: 602px; ;top:450px; opacity: .5; }

这个不需要 content,因为盒子不是伪元素。不过也没关系,骗骗浏览器也挺好。

马黑黑 发表于 2022-10-21 21:52

小辣椒 发表于 2022-10-21 21:50
黑黑我这个没有歌词同步的做好了,那今天不发,明天加歌词同步再发

也行,你把歌词先做好

小辣椒 发表于 2022-10-21 21:53

马黑黑 发表于 2022-10-21 21:52
也行,你把歌词先做好

加了首不怎么好做的歌曲,半动感的

相约爱晚亭 发表于 2022-10-21 21:54

小辣椒老师,您作品中的gif动图是用什么软件制作的?

小辣椒 发表于 2022-10-21 21:55

相约爱晚亭 发表于 2022-10-21 21:54
小辣椒老师,您作品中的gif动图是用什么软件制作的?

我在FL软件制作的

马黑黑 发表于 2022-10-21 21:57

小辣椒 发表于 2022-10-21 21:53
加了首不怎么好做的歌曲,半动感的

感觉好就成
页: [1] 2
查看完整版本: 月光小夜曲(学习黑黑何者般若播放器)