辫子哥哥 发表于 2022-12-12 11:51

海底世界


<style>
#papa { margin: 120px 0 0 calc(50% - 621px); width: 1040px; height: 694px; background: lightblue url('https://pic.imgdb.cn/item/63960f03b1fccdcd362ee277.jpg'); box-shadow: 3px 3px 20px #000; position: relative; display: grid; place-items: center; z-index: 1; }

</style>
<div id="papa"></div>
<audio id="aud" src="https://music.163.com/song/media/outer/url?id=1887097624.mp3" loop autoplay></audio>

<script>
(function() {
        (function(mkPlayer) {let defaults = {lrcAr: [],ypData: new Array(500).fill(0).map((v, k) => Math.floor(Math.random() * 200) + 10),pinpu: {size: 2.5, gap: 1,},player_css: 'left: 50%; transform: translateX(-50%); /*--color1: olive; --color2: silver*/',lrc_css:'',playerCode: `<style>#mplayer {--color1: green; --color2: lightgreen;position: absolute;bottom: 50px; left: calc(50% - 60px);width: 120px; height: 120px;border-radius: 50%;border: 6px solid var(--color1);display: grid; place-items: center center;user-select: none; cursor: pointer;}#tmsg { font: normal 14px sans-serif; color: var(--color1); text-shadow: 1px 1px 1px #000; z-index: 650; }#lrc {--motion: cover2;--tt: 2s;--state: paused;--bg: linear-gradient(180deg, hsla(120, 50%, 50%, .45), hsla(120, 100%, 50%, .75));position: absolute; left: 100px; top: 100px;font:bold 2.4em sans-serif;color: hsl(0, 10%, 90%);white-space: pre;-webkit-background-clip: text;filter: drop-shadow(1px 1px 2px hsla(0, 0%, 0%, .95));} #lrc::before {position: absolute;content: attr(data-lrc);width: 20%;height: 100%;color: transparent;overflow: hidden;white-space: pre;background: var(--bg);filter: inherit;-webkit-background-clip: text;animation: var(--motion) var(--tt) linear forwards;animation-play-state: var(--state);}.mLine { --hh: 0px; position: absolute; width: 2px; height: 6px; background: var(--color1); }.mLine::before, .mLine::after {position: absolute;content: '';width: 100%;height: var(--hh); }.mLine::before { bottom: 0;left: 0;background: linear-gradient(to top, var(--color1), var(--color2)); }.mLine::after { top: 0;left: 0;background: linear-gradient(to bottom, var(--color1), var(--color2)); }@keyframes cover1 {from {width: 0;} to {width: 100%;}}@keyframes cover2 {from {width: 0;} to {width: 100%;}}</style><div id="mplayer"><span id="tmsg">play</span></div><div id="lrc" data-lrc="HCPlayer">HCPlayer--</div>`,};let playCode = (user_config) => {let data = Object.assign({}, defaults, user_config);papa.innerHTML += data.playerCode;mplayer.style.cssText += data.player_css;aud.loop = false;let ppsize = data.pinpu.size, gap = data.pinpu.gap;let mKey = 0, mFlag = true, ppnum = 0;let total = Math.floor(mplayer.clientWidth * Math.PI / (ppsize + gap));for(j=0; j< total; j++) {let ele = document.createElement('span');ele.className = 'mLine';ele.style.width = ppsize + 'px';ele.style.transform = `rotate(${j*360/total}deg) translateY(63px)`; mplayer.appendChild(ele);}let lines = document.querySelectorAll('.mLine');let max = Math.max.apply(null, data.ypData);let divide = max / mplayer.offsetHeight, coe = 10 / total / 2, plus;let update = () => {lines.forEach((item,key) => {plus = (key < total / 2 ? key : total - key) * coe * 5;item.style.setProperty('--hh',(Math.random() * ypData - 2) / 5 + plus + 'px');});if(!aud.paused) window.requestAnimationFrame(update);};mplayer.onclick = () => aud.paused ? aud.play() : aud.pause();aud.addEventListener('pause', () => mState());aud.addEventListener('playing', () => { mState(); update(); });aud.addEventListener('ended', () => { mKey = 0; ppnum = 0; aud.play(); });aud.addEventListener('timeupdate', () => {ppnum++;if (ppnum >= data.ypData.length) ppnum = 0;tmsg.innerText = '-' + toMin(aud.duration - aud.currentTime);for (j = 0; j < data.lrcAr.length; j++) {if (aud.currentTime >= data.lrcAr) {cKey = j;if (mKey === j) showLrc(data.lrcAr);else continue;}}});let mState = () => aud.paused ? lrc.style.setProperty('--state', 'paused') : lrc.style.setProperty('--state', 'running');let showLrc = (time) => {let name = mFlag ? 'cover1' : 'cover2';lrc.innerHTML = data.lrcAr;lrc.dataset.lrc = data.lrcAr.replace(/<br>/, '\n');lrc.style.setProperty('--motion', name);lrc.style.setProperty('--tt', time + 's');lrc.style.setProperty('--state', 'running');mKey += 1;mFlag = !mFlag;};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;};};mkPlayer.HCPlayer = playCode;})(this);
        let lrcAr = [
                ,
       
        ,
       
];

        let ypData = ;
        HCPlayer({
                lrcAr: lrcAr,
                ypData: ypData,
                lrc_css: '',
                player_css: '--color1:         Lime; --color2: #0042a8; left: 780px;',
                pinpu: {size: 1, gap: 0,},
        });
})();
</script>

辫子哥哥 发表于 2022-12-12 11:52

成功了{:4_170:}

辫子哥哥 发表于 2022-12-12 11:53

谢谢小辣椒,套你的代码成功{:4_208:}

辫子哥哥 发表于 2022-12-12 11:53

就换了一个音乐和图片{:4_172:}

辫子哥哥 发表于 2022-12-12 11:54

@小辣椒

梦缘 发表于 2022-12-12 14:35

很不错,欣赏您的精彩分享!{:4_178:}

红影 发表于 2022-12-12 14:36

这个场景选择得真漂亮。我暂时听不了歌曲,看不到效果。先来给辫子点赞{:4_187:}

小辣椒 发表于 2022-12-12 18:06

不错,最开始套用,后面自己修改了玩。鼓励一下{:4_178:}

小辣椒 发表于 2022-12-12 18:06

辫子哥哥 发表于 2022-12-12 11:53
谢谢小辣椒,套你的代码成功

再接再厉{:4_189:}

亦是金 发表于 2022-12-12 18:17

好听好看,好帖子!点赞!{:4_178:}

醉美水芙蓉 发表于 2022-12-12 19:47

梦油 发表于 2022-12-12 20:00

辫子朋友好聪明啊。那个播放器真漂亮。

辫子哥哥 发表于 2022-12-12 20:51

亦是金 发表于 2022-12-12 18:17
好听好看,好帖子!点赞!

谢谢{:4_187:}

辫子哥哥 发表于 2022-12-12 20:51

醉美水芙蓉 发表于 2022-12-12 19:47
辫子老师图片选得不错!

谢谢{:4_187:}

辫子哥哥 发表于 2022-12-12 20:52

梦油 发表于 2022-12-12 20:00
辫子朋友好聪明啊。那个播放器真漂亮。

现学的,不会做

辫子哥哥 发表于 2022-12-12 20:52

小辣椒 发表于 2022-12-12 18:06
再接再厉

现在看看效果不错,后面那个更加好{:4_170:}

辫子哥哥 发表于 2022-12-12 20:53

小辣椒 发表于 2022-12-12 18:06
不错,最开始套用,后面自己修改了玩。鼓励一下

感觉是不错{:4_170:}

辫子哥哥 发表于 2022-12-12 20:54

红影 发表于 2022-12-12 14:36
这个场景选择得真漂亮。我暂时听不了歌曲,看不到效果。先来给辫子点赞

继续听,到听到为止{:4_170:}

辫子哥哥 发表于 2022-12-12 20:54

梦缘 发表于 2022-12-12 14:35
很不错,欣赏您的精彩分享!

谢谢{:4_187:}

红影 发表于 2022-12-12 21:47

辫子哥哥 发表于 2022-12-12 20:54
继续听,到听到为止

看到了,频谱颜色调得特别漂亮呢{:4_187:}
页: [1] 2
查看完整版本: 海底世界