朵拉 发表于 2022-11-25 23:11

画中游 TO:冬天的雨

本帖最后由 朵拉 于 2022-11-25 23:22 编辑 <br /><br /><style>
#papa { left: -214px; width: 1024px; height: 640px; background: url('https://pic.imgdb.cn/item/6380da6716f2c2beb14661b3.jpg') 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: ''; width: 100%; height: 100%; background: url('https://638183.freep.cn/638183/t22/webp/126.gif') repeat; opacity: var(--opt); }
#mplayer { position: absolute; bottom: 20px; display: grid; grid-template-columns: auto auto; place-items: center; z-index: 9; }
#btnplay { width: 30px; height: 30px; border-radius: 50%; background: tan linear-gradient(hsla(120,100%,90%,.6), 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.4em 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(60,100%,50%,.75),hsla(120,100%,50%,.75)); filter: inherit; -webkit-background-clip: text; animation: var(--motion) var(--tt) linear forwards; animation-play-state: var(--state); }
@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">
      <div id="lrc" data-lrc="花潮lrc在线">花潮lrc在线</div>
      <div id="mplayer">
                <span id="btnplay"></span>
                <svg id="iplay" width="300" height="20">
                        <line id="track" x1="10" y1="10" x2="190" y2="10" stroke="hsla(60,40%,80%,0.5)" stroke-width="10" stroke-linecap="round" />
                        <line id="prog" x1="10" y1="10" x2="190" y2="10" stroke="hsla(0,100%,50%,0.5)" stroke-width="10" stroke-dasharray="180" stroke-dashoffset="180" stroke-linecap="round" />
                        <text id="audtime" x="200" y="15" 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 = 'http://www.kumeiwp.com/sub/filestores/2022/11/25/da1d5d24372ea0284d8ce7fb2bbe9739.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>

朵拉 发表于 2022-11-25 23:22

@冬天的雨
问好雨版,收礼物哈{:4_204:}

朵拉 发表于 2022-11-25 23:24

@马黑黑
马师好,看过来 请指正哈{:4_190:}

马黑黑 发表于 2022-11-25 23:29

朵拉 发表于 2022-11-25 23:24
@马黑黑
马师好,看过来 请指正哈

制作精美,非常好看。赞。

现在,我把播放器做了插件封装,做帖会更容易,有空去水吧后院瞧瞧

朵拉 发表于 2022-11-25 23:31

马黑黑 发表于 2022-11-25 23:29
制作精美,非常好看。赞。

现在,我把播放器做了插件封装,做帖会更容易,有空去水吧后院瞧瞧

收到,谢谢马师{:4_190:}

马黑黑 发表于 2022-11-25 23:38

朵拉 发表于 2022-11-25 23:31
收到,谢谢马师

{:4_190:}

梦缘 发表于 2022-11-26 09:55

漂亮的闪图,欣赏问好!{:4_185:}

红影 发表于 2022-11-26 12:19

这个动图效果用在这里很漂亮。欣赏朵宝好帖。冬小雨收礼开心{:4_187:}

冬天的雨 发表于 2022-11-26 18:20

谢谢小朵拉{:4_187:}

冬天的雨 发表于 2022-11-26 18:21

朵拉 发表于 2022-11-25 23:22
@冬天的雨
问好雨版,收礼物哈

美图,播放器漂亮,这个冬雨还不会做{:4_189:}

冬天的雨 发表于 2022-11-26 18:22

红影 发表于 2022-11-26 12:19
这个动图效果用在这里很漂亮。欣赏朵宝好帖。冬小雨收礼开心

美女一起欣赏{:4_208:}
页: [1]
查看完整版本: 画中游 TO:冬天的雨