狐言
<style>#papa { margin: 0 0 0 calc(50% - 721px); display: grid; place-items: center; width: 1280px; height: 800px; background: tan url('https://638183.freep.cn/638183/t22/animal/fox.webp') no-repeat center/cover; box-shadow: 6px 3px 20px #000; user-select: none; overflow: hidden; perspective: 1500px; opacity: .95; position: relative; z-index: 1; }
#papa::before, #papa::after {position: absolute;content: '';background: url('https://638183.freep.cn/638183/t22/animal/fox1.jpg') no-repeat center/cover;width: 200px;height: 200px;top: 4px;border-radius: 50%;filter: blur(1px) brightness(20%);box-shadow: 2px 4px 18px #000;}
#papa::after { width: 60px; height: 60px; top: calc(100% - 110px); left: 260px; filter: blur(0) brightness(100%) opacity(55%); }
#btnMsg { position: absolute; left: 40%; color: snow; background: green; opacity: 0; border: 2px solid snow; border-radius: 8px; padding: 4px; transition: all .75s; cursor: pointer; z-index: 1001; }
</style>
<div id="papa"> <span id="btnMsg">全屏观赏</span></div>
<audio id="aud" src="https://music.163.com/song/media/outer/url?id=440796384.mp3" autoplay loop></audio>
<script >
(function() {
(function(mkPlayer) {let defaults = {lrcAr: [],lrc_css: 'top: 15px; left: 50%; transform: translate(-50%)',player_css: 'bottom: 5px; left: 50%; transform: translate(-50%)',playerCode: `<style>#mplayer {--ww: 300px;--hh:100px;--state: paused;position: absolute;width: var(--ww);height: var(--hh);transform-style: preserve-3d;animation: rot3d 120s infinite linear;animation-play-state: var(--state);cursor: pointer;z-index: 889;}.mline {position: absolute;width: 8px;height: 10px;bottom: 0;left: calc(50% - 4px);border-radius: 10px;transition: .35s;opacity: .95;}.mline::before {position: absolute;content: '';width: 12px;height: 12px;left: calc(50% - 6px);background: var(--psecolor);border-radius: 50%;transition: all var(--ts);animation: up 1s infinite;animation-play-state: var(--state);}#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%; } }@keyframes rot3d { to { transform: rotateY(1turn); } }@keyframes up { to { top: -20px; } }</style><div id="lrc" data-lrc="HCPlayer">HCPlayer</div><div id="mplayer"></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;mplayer.onclick = () => aud.paused ? aud.play() : aud.pause();let total = Math.floor(mplayer.offsetWidth / 5),mRad = Math.floor(mplayer.offsetWidth / 2);for (j = 0; j < total; j++) {let ele = document.createElement('span');ele.className = 'mline';ele.style.cssText += `background: linear-gradient(to bottom, #${Math.random().toString(16).substr(-6)}, #${Math.random().toString(16).substr(-6)});transform: rotateY(${j*360/total}deg) translateZ(${mRad}px);--psecolor: linear-gradient(135deg, #${Math.random().toString(16).substr(-6)}, #${Math.random().toString(16).substr(-6)});--ts: ${Math.random()}s;`;mplayer.appendChild(ele);}let lines = document.querySelectorAll('.mline');function update() {lines.forEach((item, key) => {let ph = aud.paused ? 0 : mplayer.offsetHeight;item.style.height = Math.random() * ph + 'px';});}aud.addEventListener('timeupdate', () => {update();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'), mplayer.style.setProperty('--state', 'paused')) : (lrc.style.setProperty('--state', 'running'), mplayer.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);};};mkPlayer.HCPlayer = playCode;})(this);
let ar = [,,];
HCPlayer({
lrcAr: ar,
lrc_css: 'left: 25px; top: 15px; --bg: linear-gradient(180deg,hsla(120,100%,50%,.35),hsla(120,50%, 35%,.65));',
player_css: '--ww:400px; --hh: 100px; left: 100px; bottom: 80px;',
});
let fs = false, timerId;
btnMsg.style.opacity = '0';
btnMsg.onclick = () => fs ? document.exitFullscreen() : papa.requestFullscreen();
papa.onmousemove = () => {
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 = '全屏观赏';
}
});
})();
</script>
本帖最后由 马黑黑 于 2022-12-25 08:02 编辑
帖子代码
<style>
#papa { margin: 0 0 0 calc(50% - 721px); display: grid; place-items: center; width: 1280px; height: 800px; background: tan url('https://638183.freep.cn/638183/t22/animal/fox.webp') no-repeat center/cover; box-shadow: 6px 3px 20px #000; user-select: none; overflow: hidden; perspective: 1500px; opacity: .95; position: relative; z-index: 1; }
#papa::before, #papa::after {position: absolute;content: '';background: url('https://638183.freep.cn/638183/t22/animal/fox1.jpg') no-repeat center/cover;width: 200px;height: 200px;top: 4px;border-radius: 50%;filter: blur(1px) brightness(20%);box-shadow: 2px 4px 18px #000;}
#papa::after { width: 60px; height: 60px; top: calc(100% - 110px); left: 260px; filter: blur(0) brightness(100%) opacity(55%); }
#btnMsg { position: absolute; left: 40%; color: snow; background: green; opacity: 0; border: 2px solid snow; border-radius: 8px; padding: 4px; transition: all .75s; cursor: pointer; z-index: 1001; }
</style>
<div id="papa"> <span id="btnMsg">全屏观赏</span></div>
<audio id="aud" src="https://music.163.com/song/media/outer/url?id=440796384.mp3" autoplay loop></audio>
<script >
(function() {
(function(mkPlayer) {let defaults = {lrcAr: [],lrc_css: 'top: 15px; left: 50%; transform: translate(-50%)',player_css: 'bottom: 5px; left: 50%; transform: translate(-50%)',playerCode: `<style>#mplayer {--ww: 300px;--hh:100px;--state: paused;position: absolute;width: var(--ww);height: var(--hh);transform-style: preserve-3d;animation: rot3d 120s infinite linear;animation-play-state: var(--state);cursor: pointer;z-index: 889;}.mline {position: absolute;width: 8px;height: 10px;bottom: 0;left: calc(50% - 4px);border-radius: 10px;transition: .35s;opacity: .95;}.mline::before {position: absolute;content: '';width: 12px;height: 12px;left: calc(50% - 6px);background: var(--psecolor);border-radius: 50%;transition: all var(--ts);animation: up 1s infinite;animation-play-state: var(--state);}#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%; } }@keyframes rot3d { to { transform: rotateY(1turn); } }@keyframes up { to { top: -20px; } }</style><div id="lrc" data-lrc="HCPlayer">HCPlayer</div><div id="mplayer"></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;mplayer.onclick = () => aud.paused ? aud.play() : aud.pause();let total = Math.floor(mplayer.offsetWidth / 5),mRad = Math.floor(mplayer.offsetWidth / 2);for (j = 0; j < total; j++) {let ele = document.createElement('span');ele.className = 'mline';ele.style.cssText += `background: linear-gradient(to bottom, #${Math.random().toString(16).substr(-6)}, #${Math.random().toString(16).substr(-6)});transform: rotateY(${j*360/total}deg) translateZ(${mRad}px);--psecolor: linear-gradient(135deg, #${Math.random().toString(16).substr(-6)}, #${Math.random().toString(16).substr(-6)});--ts: ${Math.random()}s;`;mplayer.appendChild(ele);}let lines = document.querySelectorAll('.mline');function update() {lines.forEach((item, key) => {let ph = aud.paused ? 0 : mplayer.offsetHeight;item.style.height = Math.random() * ph + 'px';});}aud.addEventListener('timeupdate', () => {update();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'), mplayer.style.setProperty('--state', 'paused')) : (lrc.style.setProperty('--state', 'running'), mplayer.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);};};mkPlayer.HCPlayer = playCode;})(this);
let ar = [,,];
HCPlayer({
lrcAr: ar,
lrc_css: 'left: 25px; top: 15px; --bg: linear-gradient(180deg,hsla(120,100%,50%,.35),hsla(120,50%, 35%,.65));',
player_css: '--ww:400px; --hh: 100px; left: 100px; bottom: 80px;',
});
let fs = false, timerId;
btnMsg.style.opacity = '0';
btnMsg.onclick = () => fs ? document.exitFullscreen() : papa.requestFullscreen();
papa.onmousemove = () => {
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 = '全屏观赏';
}
});
})();
</script>
插件参数配置:
一、lrcAr :设定歌词数组(略)
二、lrc_css :歌词位置、颜色等设置(略)
三、player_css :两个CSS变量 ① --ww: ??px; 频谱父元素宽度 ② --hh: ??px; 频谱父元素高度。另,和 lrc_css 参数一样,可用 left/right 和 top/bottom 两两配对设置频谱在帖子中的位置。 本帖音频播放控制器插件解决了送给小辣椒那个立体播放器中鼠标指针在手型和斜三角形来回变换以及播放器点击范围会扩展的问题。 这个好复杂。烧你脑呵。可是我喜欢。{:4_173:} 能不能把那只换成银狐哇 本帖最后由 马黑黑 于 2022-12-25 08:29 编辑
樵歌 发表于 2022-12-25 08:20
这个好复杂。烧你脑呵。可是我喜欢。
感觉已经很简化了,最初设计时参数还多一些 樵歌 发表于 2022-12-25 08:21
能不能把那只换成银狐哇
银狐是特别保护的,不敢用,生怕动物爱好者协会找上门 月亮(是月亮吗?)上的狐似乎更漂亮。 梦油 发表于 2022-12-25 09:29
月亮(是月亮吗?)上的狐似乎更漂亮。
窈窕淑女君子好逑的那类,只能更漂亮一些吧{:4_170:} 播放器里面的那只狐狸头像怎么进去的?#papa::after里没看到图片地址啊,哦,看到了,哈哈,是before和after一起设置的,after里的只是重新设置了大小位置和表现方式{:4_173:} 马黑黑 发表于 2022-12-25 08:01
本帖音频播放控制器插件解决了送给小辣椒那个立体播放器中鼠标指针在手型和斜三角形来回变换以及播放器点击 ...
“播放器点击范围会扩展”这个也感觉到了,还以为是我的错觉,原来是真的{:4_173:} 这狐仰着头,不言不动,是在修炼么{:4_173:} 越完善越是完美了,黑黑辛苦了{:4_187:} 红影 发表于 2022-12-25 10:02
播放器里面的那只狐狸头像怎么进去的?#papa::after里没看到图片地址啊,哦,看到了,哈哈,是before和afte ...
这是小技巧:重复的东东放在一起设置(如果可以),不同的单独弄一下 红影 发表于 2022-12-25 10:04
这狐仰着头,不言不动,是在修炼么
狐言与人言方式不同 红影 发表于 2022-12-25 10:03
“播放器点击范围会扩展”这个也感觉到了,还以为是我的错觉,原来是真的
原来的机制,chromium浏览器下会这样(有点不科学) 红影 发表于 2022-12-25 10:04
越完善越是完美了,黑黑辛苦了
玩CSS的transform也不是一天两天的事情了,算是老手了,还是掉坑 马黑黑 发表于 2022-12-25 08:28
感觉已经很简化了,最初设计时参数还多一些
没办法,隔行如隔山哪{:4_203:} 马黑黑 发表于 2022-12-25 08:29
银狐是特别保护的,不敢用,生怕动物爱好者协会找上门
来了打走这些假道学。我最恨一些所谓的“爱狗人士”了,白天做着关爱动物,晚上就偷狗去卖钱钱!我以前晚上在河边钓鱼时,就发现一些爱狗人士偷狗!