宁静 发表于 2022-12-31 20:56

祝东篱论坛的朋友们元旦快乐

本帖最后由 宁静 于 2024-9-23 11:32 编辑 <br /><br /><style>
#papa { margin: 120px 0 0 calc(50% - 493px); display: grid; place-items: center; width: 1024px; height: 640px; background: gray url('https://wj.zp68.com/lxx/yunhua/2022/12/31/IF.gif') no-repeat center/cover; box-shadow: 3px 3px 20px #000; user-select: none; position: relative; z-index: 1; }
#papa:hover #fullscreen { display: block; }
#fullscreen { position: absolute; bottom: 140px; color: snow; text-shadow: 1px 1px 2px #000; display: none; cursor: pointer; }
</style>

<div id="papa">
        <img src="https://wj.zp68.com/lxx/yunhua/2022/12/31/27.gif" alt="" style="position: absolute; bottom: 100px; mix-blend-mode: " />
        <span id="fullscreen">全屏观赏</span>
</div>
<audio id="aud" src="https://wj.zp68.com/lxx/yunhua/2022/12/31/tdkl.mp3" loop autoplay></audio>

<script >
(function() {
        (function(mkPlayer) {let defaults = {lrcAr: [],lrc_css: 'top: 15px; left: 50%; transform: translate(-50%)',player_css: 'bottom: 10px; left: 50%; transform: translate(-50%)',playerCode: `<style>#mplayer { --ww: 300px; --color1: hsla(0,80%,50%,.95); --color2: hsla(0,0%,95%,.45); position: absolute; 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.6em sans-serif; color: hsl(0, 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><canvas id="mplayer" width="300" height="75"></canvas><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;let mKey = 0, mFlag = true, btfFlag = false;let getCssVal = (e,v) => getComputedStyle(e).getPropertyValue(v);let ctx = mplayer.getContext('2d');let w = mplayer.width = getCssVal(mplayer,'--ww').replace(/[^0-9]/ig,''), h = mplayer.height = 75;let btnFlag = false;let player = {prog: 0,track: w,color: ,cur: '00:00',dur: '00:00'};let drawCircle = (x,y,r,color) => {ctx.beginPath();ctx.strokeStyle = color;ctx.lineWidth = 2;ctx.arc(x,y,r,0,2*Math.PI);ctx.stroke();};let drawTriangle = (x,y,len,color) => {ctx.beginPath();ctx.fillStyle = color;ctx.moveTo(x,y);ctx.lineTo(x, y+len);ctx.lineTo(x+len, y + len/2);ctx.lineTo(x,y);ctx.fill();};let drawRect = (x,y,ww,hh,color) => {ctx.beginPath();ctx.fillStyle = color;ctx.fillRect(x,y,ww,hh);};let drawOsc = (w1,w2) => {ctx.beginPath();ctx.lineWidth = 1;ctx.strokeStyle = player.color;let slice = 1, tt1 = Math.round(w1/slice), tt2 = Math.round(w2/slice);for(j=0; j<=tt2; j++) {ctx.lineTo(j*slice, Math.random() *30);}ctx.stroke();ctx.beginPath();ctx.strokeStyle = player.color;for(j=tt2; j<tt1; j++) {ctx.lineTo(j*slice, Math.random() *30);}ctx.stroke();};let drawTxt = (text,x,y,align,color) => {ctx.beginPath();ctx.font = '16px sans-serif';ctx.textAlign = align;ctx.textBaseline = 'middle';ctx.fillStyle = color;ctx.fillText(text,x,y);};let btnRender = () => {let btnColor = btnFlag ? player.color : player.color;ctx.clearRect(w/2-18, h-38, 36, 36);drawCircle(w/2,h-20,16,btnColor);aud.paused ? drawTriangle(w/2-6,h-28,16,btnColor) : (drawRect(w/2-6, h-28,4,16,btnColor), drawRect(w/2+2, h-28,4,16,btnColor));};let drawAll = () => {ctx.clearRect(0,0,w,h);drawOsc(w,player.prog);drawTxt(player.cur,w/2-26,h-20,'right',player.color);drawTxt(player.dur,w/2 + 26,h-20,'left',player.color);btnRender();};let overBtn = (e) => Math.sqrt((e.offsetX-w/2) ** 2 + (e.offsetY-(h-20)) ** 2) < 16;let overProg = (e) => e.offsetY > 0 && e.offsetY < 30;mplayer.onmousemove = (e) => {mplayer.style.cursor = overBtn(e) || overProg(e) ? 'pointer' : 'default';mplayer.title = overProg(e) ? toMin(e.offsetX*aud.duration/w) : '';overBtn(e) ? (btnFlag = true,btnRender()) : (btnFlag = false,btnRender());};mplayer.onclick = (e) => {if(overBtn(e)) { aud.paused ? aud.play() : aud.pause(); drawAll(); }if(overProg(e)) aud.currentTime = aud.duration * e.offsetX / w;};mplayer.onmouseout = () => { btnFlag = false; btnRender(); };aud.addEventListener('timeupdate', () => {player.prog = aud.currentTime * w /aud.duration;player.cur = toMin(aud.currentTime);player.dur = toMin(aud.duration);drawAll();for (j = 0; j < data.lrcAr.length; j++) {if (aud.currentTime >= data.lrcAr) {if (mKey === j) showLrc(data.lrcAr);else continue;}}});aud.addEventListener('pause', () => mState());aud.addEventListener('play', () => mState());aud.addEventListener('seeked', () => calcKey());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 calcKey = () => {for (j = 0; j < data.lrcAr.length; j++) {if (aud.currentTime <= data.lrcAr) {mKey = j - 1;break;}}if (mKey < 0) mKey = 0;if (mKey > data.lrcAr.length - 1) mKey = data.lrcAr.length - 1;let time = data.lrcAr - (aud.currentTime - data.lrcAr);showLrc(time);};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;};drawAll();};mkPlayer.HCPlayer = playCode;})(this);
        let lrcAr = [
               ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
                ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
               
];
        HCPlayer({
                lrcAr: lrcAr,
                player_css: '--color1: Lime; --color2: Yellow; --ww: 400px; bottom: 5px;',
                lrc_css: '--bg: linear-gradient(180deg,hsla(120,100%,50%,.35),hsla(120,100%,50%,.65)); color: Yellow; top: 150px;',
        });
        let fs = true;
        fullscreen.onclick = () => {
                fs ? (fullscreen.innerText = '退出全屏', papa.requestFullscreen()) : (fullscreen.innerText = '全屏观赏', document.exitFullscreen());
                fs = !fs;
        };
})();
</script>

<br><br><br><br>

宁静 发表于 2022-12-31 20:56

点击画面中宝宝欣赏全屏效果

宁静 发表于 2022-12-31 20:57

祝东篱论坛的朋友们元旦快乐

宁静 发表于 2022-12-31 20:57

2022赶走羊羊 迎接新的一年到来

浅笑 发表于 2022-12-31 21:05

宁静元旦快乐{:10_401:}

宁静 发表于 2022-12-31 21:07

浅笑 发表于 2022-12-31 21:05
宁静元旦快乐

笑笑一起快乐~~{:10_401:}

撒哈拉的雨 发表于 2022-12-31 21:11

宁静 发表于 2022-12-31 20:56
点击画面中宝宝欣赏全屏效果

全屏效果很漂亮的,这个过几天我学习一下试试

撒哈拉的雨 发表于 2022-12-31 21:11

宁静 发表于 2022-12-31 20:57
2022赶走羊羊 迎接新的一年到来

早点休息吧

宁静 发表于 2022-12-31 21:12

撒哈拉的雨 发表于 2022-12-31 21:11
早点休息吧

刚准备下的,你睡前上来了。你也是好好休息,我下的

撒哈拉的雨 发表于 2022-12-31 21:13

宁静 发表于 2022-12-31 21:12
刚准备下的,你睡前上来了。你也是好好休息,我下的

好的,还是要多喝水
页: [1] 2 3
查看完整版本: 祝东篱论坛的朋友们元旦快乐