宁静 发表于 2023-1-25 21:55

致曾经----动感音乐欣赏

本帖最后由 宁静 于 2023-2-22 13:48 编辑 <br /><br /><meta charset="UTF-8">
<style>
#papa { margin: 120px 0 0 calc(50% - 720px); width: 1280px; height: 700px; background: lightblue url('https://yinhua.ru/20221211/012.jpg') no-repeat center/cover; box-shadow: 3px 3px 20px #000; position: relative; display: grid; place-items: center; overflow: hidden; z-index: 1; }
#papa::before { position: absolute; content: '';background: url('https://wj.zp68.com/lxx/yunhua/2022/12/11/1IF.gif') no-repeat center/cover; opacity: .45; width: 100%; height: 100%; animation: scale 8s infinite alternate linear; }
.mLine:nth-of-type(odd) { background: linear-gradient(to top,green,DarkCyan); }
.mLine::before { position: absolute; content: ''; width: 100%; height:6px; border-radius: 50%; background: lightblue; top: 0; animation: up 1.2s infinite alternate linear; }
@keyframes up{ to {top: -40px; } }
@keyframes scale { to {transform: scale(1.2); } }
</style>

<div id="papa"></div>
<audio id="aud" src="https://yinhua.ru/20221211/zcj.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: 4, gap: 2,},player_css: '',lrc_css: '',playerCode: `<style>#mplayer {--ww: 300px;--hh: 140px; --color1: darkgreen; --color2: snow);position: absolute;bottom: 10px;width: var(--ww);height: var(--hh);display: flex;justify-content: center;align-items: flex-end;cursor: pointer;}.mLine {position: relative;margin: 0 1px 0 1px;width: 4px;height: 8px;background: linear-gradient(to top,var(--color1),var(--color2));transition: .35s;opacity: .95;}#lrc {--motion: cover2;--tt: 2s;--state: paused;--bg: linear-gradient(180deg, hsla(120, 50%, 50%, .45), hsla(120, 100%, 50%, .75));position: absolute;top: 80px;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);}@keyframes cover1 {from {width: 0;} to {width: 100%;}}@keyframes cover2 {from {width: 0;} to {width: 100%;}}</style><div id="mplayer"></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;mplayer.onclick = () => aud.paused ? aud.play() : aud.pause();aud.loop = false;let ppsize = data.pinpu.size || 4, gap = data.pinpu.gap || 2;let total = Math.ceil(mplayer.offsetWidth / (ppsize + gap));let mKey = 0,ppnum = 0, mFlag = true;for (j = 0; j < total; j++) {let el = document.createElement('span');el.className = 'mLine';el.style.width = ppsize + 'px';el.style.marginLeft = el.style.marginRight = gap/2 + 'px';mplayer.appendChild(el);}let lines = document.querySelectorAll('.mLine');let max = Math.max.apply(null, data.ypData);let divide = max / mplayer.offsetHeight, coe = 20 / total / 2, plus;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;update();for (j = 0; j < data.lrcAr.length; j++) {if (aud.currentTime >= data.lrcAr) {cKey = j;if (mKey === j) showLrc(data.lrcAr);else continue;}}});let update = () => lines.forEach((item, key) => {plus = (key < total / 2 ? key : total - key) * coe * 10;item.style.setProperty('height', Math.random() * (data.ypData - 30) / divide + plus + 'px');});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;};};mkPlayer.HCPlayer = playCode;})(this);
        let lrcAr = [
                ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,];
        ypData = ;
        HCPlayer({
                lrcAr: lrcAr,
                ypData: ypData,
                lrc_css: '',
                player_css: '--ww: 100%; --hh: 240px; --color1:Crimson; --color2: Yellow; bottom: 0;',
                pinpu: {size: 6,gap: 2},
        });
})();
</script>
<br><br><br><br>

宁静 发表于 2023-1-25 21:56

频谱播放器,点击频谱音乐停止

宁静 发表于 2023-1-25 21:56

@撒哈拉的雨

宁静 发表于 2023-1-25 22:12

这个会动图可以试着做一次

宁静 发表于 2023-1-25 22:13

最好是动感音乐,但音频要制作一下的。否则音乐频谱和音乐的节奏不符

宁静 发表于 2023-1-25 22:14

今天超出10点了{:9007:}

沉默 发表于 2023-1-26 12:01

宁静 发表于 2023-1-25 21:56
频谱播放器,点击频谱音乐停止

忘记曾经,新的一年开始了

沉默 发表于 2023-1-26 12:02

收礼,送礼的都开心{:10_402:}

沉默 发表于 2023-1-26 12:05

最后一个在这里回帖,看看运气{:9001:}

蜻蜓 发表于 2023-1-26 13:19

超酷的{:10_402:}
页: [1] 2 3
查看完整版本: 致曾经----动感音乐欣赏