|
|

楼主 |
发表于 2023-2-1 10:34
|
显示全部楼层
我把代码贴出来你看看
- <style>
- #papa { margin: 0 0 0 calc(50% - 593px); display: grid; place-items: center; width: 1024px; height: 640px; background: gray url('https://638183.freep.cn/638183/t23/webp/dance.webp') no-repeat center/cover; overflow: hidden; user-select: none; box-shadow: 6px 3px 20px #000; position: relative; perspective: 3000px; z-index: 1; }
- </style>
- <div id="papa"></div>
- <audio id="aud" src="https://music.163.com/song/media/outer/url?id=2007543778.mp3" loop autoplay></audio>
- <script >
- (function() {
- (function(mkPlayer) {let defaults = {lrcAr: [[2,"花潮LRC在线",3],[6,"",1]],ttAr: ['花潮','论坛','LRC','在线'],lrc_css: 'top: 20px; left: 50%; transform: translateX(-50%);',player_css: 'bottom: 20px; left: calc(50% - 50px);', playerCode: `<style>#mplayer {--bg: linear-gradient(to right bottom,olive,black);position: absolute;width: 100px;height: 100px;display: grid;place-items: center;animation: rot 10s infinite linear;cursor: pointer;color: snow;transform-style: preserve-3d;}.pedal {position: absolute;width: 100px;height: 100px;background: var(--bg);font: bold 2em sans-serif;display: grid;place-items: center;opacity: .95;}.pedal:nth-of-type(1) { transform: rotateY(45deg) translateZ(50px); }.pedal:nth-of-type(2) { transform: rotateY(135deg) translateZ(50px); }.pedal:nth-of-type(3) { transform: rotateY(-135deg) translateZ(50px); }.pedal:nth-of-type(4) { transform: rotateY(-45deg) translateZ(50px); }#btnMsg { position: absolute; color: snow; background: #666; opacity: 0; border: 2px solid snow; border-radius: 8px; padding: 4px; transition: all .75s; cursor: pointer; z-index: 901; }#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 rot { to { transform: rotateY(-1turn); } }@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"><span class="pedal"></span><span class="pedal"></span><span class="pedal"></span><span class="pedal"></span></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, tnow = Date.now(), timerId;;data.ttAr.forEach( (item,key) => {let spans = mplayer.children;spans[key].innerText =item;});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', () => mState());aud.addEventListener('seeked', () => calcKey());let mState = () => aud.paused ? (lrc.style.setProperty('--state','paused'), mplayer.style.animationPlayState='paused') : (lrc.style.setProperty('--state','running'), mplayer.style.animationPlayState='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);
- let lrcAr = [[1,"Ava Max : Dancing's Done",3],[10.68,"I see the panic somewhere in your eyes",3.7],[14.4,"Yeah in your eyes",2.4],[19.05, "I don't wanna tell but it brought us here tonight",3.7],[22.74,"Yeah back to life",1.8],[24.87,"If you're gonna leave me hangin'",2.4],[27.27,"Then you gonna leave me dead",1.9],[29.21,"I'm never going home",2.0],[31.2,"If you're not there",2.1],[33.69,"I wanna give in to your dark temptation",4.6],[38.24,"I wanna touch you like nobody does oh",4.1],[42.36,"People like you and me were born to run",3.8],[46.14,"So where we going when the dancing's done? (Oh)",4.4],[50.77,"I wanna give in to your dark temptation",4.0],[54.76,"I wanna touch you like nobody does oh",4.4],[59.13,"People like you and me were born to run",3.8],[62.97,"So where we going when the dancing's done?",4.4],[78.22,"I wanna taste the secrets that you hide",3.4],[81.81,"And make 'em mine (Ah)",3.0],[86.42,"Come take me to the edge of afterlife",3.6],[90.02,"And take your time",1.7],[92.26,"If you're gonna leave me hangin'",2.1],[94.39,"Then you gonna leave me dead",2.2],[96.61,"I'm never going home",2.0],[98.59,"If you're not there (Oh)",2.4],[101.33,"I wanna give in to your dark temptation",4.2],[105.54,"I wanna touch you like nobody does oh",4.2],[109.72,"People like you and me were born to run",3.7],[113.4,"So where we going when the dancing's done?",4.7],[118.06,"I wanna give in to your dark temptation",4.2],[122.22,"I wanna touch you like nobody does oh",4.2],[126.42,"People like you and me were born to run",3.7],[130.14,"So where we going when the dancing's done?",4.2],[134.86," Oh oh oh oh oh",8.2],[149.07," When the dancing's done",3.8],[157.08," When the dancing's done",4.8]];
- HCPlayer({
- lrcAr: lrcAr,
- lrc_css: '--bg: linear-gradient(hsla(180,80%,60%,.7),hsla(220,70%,40%,.5)); top: 5px;',
- ttAr: ['','','',''],
- player_css: '--bg: repeating-linear-gradient(90deg, transparent, black 8px, silver 16px); top: 80px; color: lightblue;',
- });
- })();
- </script>
复制代码 播放器插件和昨天在音乐版发的一模一样,不同的是参数配置,这一句:
player_css: '--bg: repeating-linear-gradient(90deg, transparent, black 8px, silver 16px); top: 80px; color: lightblue;',
红色部分,表示背景使用 重复性线性渐变
|
|