|
|

楼主 |
发表于 2023-1-1 09:35
|
显示全部楼层
本帖测试电波插件
- <style>
- #papa { margin: 0px 0 0 calc(50% - 593px); display: grid; place-items: center; width: 1024px; height: 640px; background: url('https://638183.freep.cn/638183/t23/webp/Indian.webp') no-repeat center/cover; background-blend-mode: normal, color; box-shadow: 3px 3px 20px #000; user-select: none; position: relative; z-index: 1; }
- #papa::before { position: absolute; content: ''; top: 85px; right: 80px; width: 300px; height: 300px; background: url('https://638183.freep.cn/638183/t23/webp/horse.webp') no-repeat center/cover; transform: rotate(45deg); }
- </style>
- <div id="papa"></div>
- <audio id="aud" src="https://music.163.com/song/media/outer/url?id=1464475270.mp3" loop autoplay></audio>
- <script >
- (function() {
- (function(mkPlayer) {let defaults = {lrcAr: [ [2.6, "花潮LRC在线", 3] ],lrc_css: 'top: 20px; left: 50%; transform: translateX(-50%);',player_css: 'bottom: 20px; left: calc(50% - var(--ww) / 2);', playerCode: `<style>#mplayer { --ww: 200px; --btn: tan; position: absolute; width: var(--ww); height: var(--ww); display: grid; place-items: center; cursor: pointer; z-index: 899; }#mplayer::before { position: absolute; content: ''; width: 30px; height: 30px; border-radius: 50%; background: var(--btn); }#btnMsg { position: absolute; color: snow; background: green; opacity: 0; border: 2px solid snow; border-radius: 8px; padding: 4px; transition: all .75s; cursor: pointer; z-index: 901; }.circle { position: absolute; width: 20px; height: 20px; border: 1px solid olive; border-radius: 50%; transition: all .45s; }#lrc { --motion: cover2; --tt: 1s; --state: running; --bg: linear-gradient(180deg,hsla(100,10%,50%,.75),hsla(100,100%,20%,.65)); position: absolute; font: bold 2.4em sans-serif; color: hsl(100, 100%, 90%); white-space: pre; -webkit-background-clip: text; filter: drop-shadow(1px 1px 2px hsla(0, 100%, 0%, .85)); z-index: 900; }#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="lrc" data-lrc="HCPlayer">HCPlayer</div><div id="mplayer"></div><span id="btnMsg">全屏观赏</span>`,};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;let mKey = 0, mFlag = true, fs = false, timerId;let circles = [], tnow = Date.now();[...Array(30).keys()].forEach( (item) => {let size = Math.random()* mplayer.offsetWidth;let styles = ['solid','dotted','dashed'];item = document.createElement('span');item.className = 'circle';item.style.cssText += `width: ${size}px;height: ${size}px;border: ${Math.round(Math.random())+1}px ${styles[Math.round(Math.random() * 3)]} #${Math.random().toString(16).substr(-6)};`;circles.push(item);mplayer.appendChild(item);});let update = () => {for(item of circles) {let size = aud.paused ? 0 : Math.random()* mplayer.offsetWidth;item.style.width = item.style.height = size + 'px';}setTimeout(update, 200);};mplayer.onclick = () => aud.paused ? aud.play() : aud.pause();btnMsg.onclick = () => fs ? document.exitFullscreen() : papa.requestFullscreen();papa.onmousemove = (e) => {clearTimeout(timerId);btnMsg.style.opacity = '.95';timerId = setTimeout('btnMsg.style.opacity = "0"', 3000);};document.addEventListener("fullscreenchange", () => {if (document.fullscreenElement !== null) {fs = true;btnMsg.innerText = '退出全屏';} else {fs = false;btnMsg.innerText = '全屏观赏';}});aud.addEventListener('pause', () => mState());aud.addEventListener('play', () => {update(); mState(); });aud.addEventListener('seeked', () => aud.play());let mState = () => lrc.style.setProperty('--state', aud.paused ? 'paused' : 'running');aud.addEventListener('timeupdate', () => {for (j = 0; j < data.lrcAr.length; j++) {if (aud.currentTime >= data.lrcAr[j][0]) {if (mKey === j) showLrc(data.lrcAr[j][2]);else continue;}}});let showLrc = (time) => {let name = mFlag ? 'cover1' : 'cover2';lrc.innerHTML = data.lrcAr[mKey][1];lrc.dataset.lrc = data.lrcAr[mKey][1].replace(/<br>/, '\n');lrc.style.setProperty('--motion', name);lrc.style.setProperty('--tt', time + 's');lrc.style.setProperty('--state', 'running');mKey += 1;mFlag = !mFlag;};let calcKey = () => {for (j = 0; j < data.lrcAr.length; j++) {if (aud.currentTime <= data.lrcAr[j][0]) {mKey = j - 1;break;}}if (mKey < 0) mKey = 0;if (mKey > data.lrcAr.length - 1) mKey = data.lrcAr.length - 1;let time = data.lrcAr[mKey][2] - (aud.currentTime - data.lrcAr[mKey][0]);showLrc(time);};};mkPlayer.HCPlayer = playCode;})(this);
- HCPlayer({
- lrcAr: [[2,"纯音乐 - 马",4],[10,"",1]],
- lrc_css: 'bottom: 15px; left: 20px;',
- player_css: '--ww: 260px; --btn: transparent; top: 0px; right: 50px;',
- });
- })();
- </script>
复制代码 接口参数 lrcAr、lrc_css 请参考以往相关插件,player_css 参数多一个CSS变量 --btn ,用于定义播放器中心圆的颜色,支持各种颜色表达法(含渐变背景色)。
|
|