红影 发表于 2022-11-22 12:07

瞒 (学习黑黑手链按钮+progress封装并加外套)


<style>
#papa { margin: 120px 0 0 calc(50% - 681px); width: 1200px; height: 595px; display: grid; place-items: center; background: #0b1a3a; box-shadow: 3px 3px 20px #000; display: grid; place-items: center; overflow: hidden; position: relative; z-index: 1; }
#tu {position: absolute; right: 0px; top: 0px;opacity: 1; animation: flash linear 1.2sinfinite alternate; }
@keyframes flash { to { opacity: .5; } }
</style>
<div id="papa">
      <img id="tu" src="https://pic.imgdb.cn/item/637c3a5216f2c2beb18a3d05.jpg" alt="" /></div>
        <audio id="aud" src="http://www.kumeiwp.com/sub/filestores/2022/11/03/9205c9e65cc55a369c6c4f135bba4da1.mp3" loop autoplay></audio>

<script >
(function() {
(function(mkPlayer) {let defaults = {lrcAr: [],lrc_css: 'top: 10px; left: 50%; transform: translateX(-50%);',player_css: 'bottom: 20px; left: 50%; transform: translateX(-50%);',btn_size: '40px',playerCode: `<style>#mplayer {position: absolute;display: grid;grid-template-areas: 'cur btnplay dur''prog prog prog';gap: 2px 6px;place-items: end center;color: var(--color);font: normal 16px sans-serif;z-index: 999;--ww: 260px;--color: hsl(0, 100%, 100%);}#btnplay {grid-area: btnplay;--state: paused;width: 40px;height: 40px;cursor: pointer;display: grid;place-items: center;animation: rot linear 3s infinite;position: relative;animation: rot 3s linear infinite;animation-play-state: var(--state);}#btnplay > span {position: absolute;width: 10px;height: 10px;border-radius: 50%;background: linear-gradient(tan,red);}#prog {grid-area: prog;width: var(--ww);height: 20px;opacity: .95;cursor: pointer;}#cur { grid-area: cur; color: var(--color); }#dur { grid-area: dur; color: var(--color); }#lrc {--motion: cover2;--tt: 2s;--state: paused;--bg: linear-gradient(180deg,hsla(60,100%,50%,.45),hsla(200,50%,50%,.75));position: absolute;left: 20px;top: 10px;font: bold 2.0em 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%; } }@keyframes rot { to { transform: rotate(1turn); } }</style><div id="lrc" data-lrc="HCPlayer">HCPlayer</div><div id="mplayer"><div id="cur">00:00</div><div id="btnplay"><span></span></div><div id="dur">00:00</div><progress id="prog" max="100"></progress></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;btnplay.style.width = btnplay.style.height = data.btn_size || '40px';let mKey = 0, mFlag = true;btnplay.onclick = () => aud.paused ? aud.play() : aud.pause();prog.onclick = (e) => aud.currentTime = aud.currentTime = aud.duration * e.offsetX / prog.offsetWidth;aud.addEventListener('timeupdate', () => {prog.value = aud.currentTime / aud.duration * 100;cur.innerText = toMin(aud.currentTime);dur.innerText = toMin(aud.duration);for (j = 0; j < data.lrcAr.length; j++) {if (aud.currentTime >= data.lrcAr) {cKey = j;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'),btnplay.style.setProperty('--state', 'paused')) : (lrc.style.setProperty('--state','running'),btnplay.style.setProperty('--state', 'running'));let showLrc = (time) => {let name = mFlag ? 'cover1' : 'cover2';lrc.innerHTML = lrcAr;lrc.dataset.lrc = 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;};(function mkSpan() {[...Array(10).keys()].forEach((ele, key) => {ele = document.createElement('span');ele.style.cssText += `background: linear-gradient(135deg, #${Math.random().toString(16).substr(-6)}, #${Math.random().toString(16).substr(-6)});transform: rotate(${key*36}deg) translate(18px)`;btnplay.appendChild(ele);});})();};mkPlayer.HCPlayer = playCode;})(this);
let lrcAr = [
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
       
];
HCPlayer({
      lrcAr: lrcAr,
      lrc_css: 'top: 20px; left: 480px; --bg: #fcff00;',
      player_css: 'bottom: 20px; left: 510px; --color: #ccc; --ww: 180px;',
});
})();
</script>

红影 发表于 2022-11-22 12:08

再学个封装效果,还剩10个没学做了。黑黑来收作业{:4_187:}

红影 发表于 2022-11-22 12:11

马上要外出了,把帖子赶紧发出来,然后,出发。希望一会不要下雨。这天看着有点危险,只要路上不下,到地方了就随便它下了。

马黑黑 发表于 2022-11-22 12:29

最后能瞒的,只有自己

闲言不语 发表于 2022-11-22 12:47

发现红影的音画品位越来越高了!{:4_199:}

朵拉 发表于 2022-11-22 14:14

背景图选的好,别瞒 大胆说出来{:4_204:}

梦油 发表于 2022-11-22 17:12

光线的强弱变化,增强了作品的魅力。

醉美水芙蓉 发表于 2022-11-22 17:45

梦缘 发表于 2022-11-22 18:39

好美的变幻夜景,感谢老师的精彩分享,欣赏点赞!{:4_185:}

小辣椒 发表于 2022-11-22 20:04

亲爱的好棒,用了图片变色,{:4_178:}

小辣椒 发表于 2022-11-22 20:05

封装并加外套都用上了{:4_178:}

小辣椒 发表于 2022-11-22 20:07

亲爱的,你活学活用的最好{:4_178:}

千羽 发表于 2022-11-22 20:43

豪华大宅院{:4_187:}

千羽 发表于 2022-11-22 20:45

看点多多,唯美又精致{:4_187:}

红影 发表于 2022-11-22 22:30

马黑黑 发表于 2022-11-22 12:29
最后能瞒的,只有自己

这歌我也没听过,跑酷美里乱翻翻到的。白天听不了网易云,不能按歌名找了{:4_173:}

红影 发表于 2022-11-22 22:30

闲言不语 发表于 2022-11-22 12:47
发现红影的音画品位越来越高了!

谢谢不语表扬,算给我增加信心的呗{:4_173:}

红影 发表于 2022-11-22 22:31

朵拉 发表于 2022-11-22 14:14
背景图选的好,别瞒 大胆说出来

是歌曲要瞒,我是从来不瞒的{:4_170:}

红影 发表于 2022-11-22 22:32

梦油 发表于 2022-11-22 17:12
光线的强弱变化,增强了作品的魅力。

这个是跟黑黑那个满天星的帖子里学的{:4_173:}

红影 发表于 2022-11-22 22:32

醉美水芙蓉 发表于 2022-11-22 17:45
欣赏红影好作品!

多谢水芙蓉美女鼓励{:4_204:}

马黑黑 发表于 2022-11-22 22:32

红影 发表于 2022-11-22 22:30
这歌我也没听过,跑酷美里乱翻翻到的。白天听不了网易云,不能按歌名找了

不错的
页: [1] 2 3 4
查看完整版本: 瞒 (学习黑黑手链按钮+progress封装并加外套)