还没有爱够(学习马黑黑老师31号播放器插件练习)
<style>
#papa { margin: 0 0 50px calc(50% - 650px); width: 1138px; height: 640px; background: gray url('https://pic.imgdb.cn/item/639735beb1fccdcd36c1dfee.jpg') no-repeat center/cover; box-shadow: 3px 6px 20px #000; display: grid; place-items: center; position: relative; z-index: 1; }
.mLine:nth-of-type(odd), .mLine:nth-of-type(even) {background: linear-gradient(to top, var(--color2),var(--color1),var(--color2)); border-radius:100%;}
/* 定义奇数位不同的颜色 */
/*.mLine:nth-of-type(odd) { --color1: hsl(30,90%,40%); }*/
</style>
<div id="papa"></div>
<audio id="aud" src="https://www.qqmc.com/up/kwlink.php?id=212925971.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: 1px; 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(60, 50%, 50%, .45), hsla(0, 100%, 50%, .75)); position:absolute; top:20px; 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;lrc.style.cssText += data.lrc_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 = [
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
];
let ypData = ;
HCPlayer({
lrcAr: lrcAr,
ypData: ypData,
lrc_css: '',
player_css: '--color1: hsl(318,100%,50%); --color2: hsla(24,0%,100%,0.15); --ww: 50%; align-items: center; bottom: 1px;',
});
})();
</script>
这个频谱很漂亮,寒冬残荷这么快就做出来了,很赞{:4_199:} 红影 发表于 2022-12-12 22:48
这个频谱很漂亮,寒冬残荷这么快就做出来了,很赞
谢谢红管理的鼓励!我因忙家务,没时间认真学习和掌握马老师传授的知识,只能偶尔上网来欣赏欣赏,看到很喜欢的就照抄试一下,也就是纯粹的“抄作业”。{:5_117:} 很漂亮啊。赞。 寒冬残荷 发表于 2022-12-12 23:05
谢谢红管理的鼓励!我因忙家务,没时间认真学习和掌握马老师传授的知识,只能偶尔上网来欣赏欣赏,看到很 ...
非常漂亮呢。一直记着寒冬残荷的好,你教我的遮罩在加图片的时候特别有用{:4_173:} 马黑黑 发表于 2022-12-12 23:07
很漂亮啊。赞。
谢谢马老师。我这是纯粹的“抄作业”。因为抄作业对理解和掌握知识有好处呵。{:5_117:} 马黑黑 发表于 2022-12-12 23:07
很漂亮啊。赞。
谢谢马老师。我这是纯粹的“抄作业”。因为抄作业对理解和掌握知识有好处呵。{:5_117:} 马黑黑 发表于 2022-12-12 23:07
很漂亮啊。赞。
谢谢马老师。我这是纯粹的“抄作业”。因为抄作业对理解和掌握知识有好处呵。{:5_117:} 马黑黑 发表于 2022-12-12 23:07
很漂亮啊。赞。
谢谢马老师。我这是纯粹的“抄作业”。因为抄作业对理解和掌握知识有好处呵。{:5_117:} 寒冬残荷 发表于 2022-12-13 00:02
谢谢马老师。我这是纯粹的“抄作业”。因为抄作业对理解和掌握知识有好处呵。
{:4_191:}
页:
[1]