本帖最后由 马黑黑 于 2024-3-10 08:44 编辑
帖子代码
<style>
#papa { margin: 0 0 0 calc(50% - 593px); width: 1024px; height: 640px; background: url('https://638183.freep.cn/638183/t24/1/orange.jpeg') no-repeat center/cover; box-shadow: 3px 3px 20px #000; overflow: hidden; z-index: 1; position: relative; }
#btnplay { position: absolute; width: 100px; left: 0; top: 10px; filter: hue-rotate(260deg) opacity(.8); transition: 6s; cursor: pointer; animation: rot 8s linear infinite var(--state); }
#vid { position: absolute; top: -130px; left: -150px; width: 400px; height: 400px; object-fit: cover; border-radius: 50%; opacity: .6; transition: 6s; mix-blend-mode: screen; pointer-events: none; }
@keyframes rot { to { transform: rotate(360deg); } }
</style>
<div id="papa">
<audio id="aud" src="https://music.163.com/song/media/outer/url?id=1495851768" autoplay loop></audio>
<video id="vid" src="https://img.tukuppt.com/video_show/15653652/00/85/69/60ff8be36ed3c.mp4" loop></video>
<img id="btnplay" src="https://638183.freep.cn/638183/web/svg/sunfl-2.svg" alt="" />
</div>
<script>
(function() {
let sF = document.createElement('script');
sF.src = 'https://638183.freep.cn/638183/web/api/fullscreen.js';
sF.charset = 'utf-8';
document.querySelector('body').appendChild(sF);
sF.onload = () => FS({papa: '#papa', css: '--bg: transparent; --color: #eee; bottom: 10px; left: 48%;'});
let mState = () => aud.paused ? (papa.style.setProperty('--state','paused'),btnplay.title = '点击播放',vid.pause()) : (papa.style.setProperty('--state','running'),btnplay.title = '点击暂停',vid.play());
let getOffsetPos = (ele) => { let x = ele.offsetLeft, y = ele.offsetTop, pa = ele.offsetParent; while(pa != null) { x += pa.offsetLeft; y += pa.offsetTop; pa = pa.offsetParent; } return {x, y}; };
aud.onplaying = aud.onpause = () => mState();
btnplay.onclick = () => aud.paused ? aud.play() : aud.pause();
let movTimer = null, paWidth = papa.clientWidth, sonSize = btnplay.clientWidth, bodyWidth = document.body.clientWidth, paOffset = getOffsetPos(papa).x;
document.onmousemove = function(e) {clearTimeout(movTimer); movTimer = setTimeout(function() { if (e.target.id === "player" || e.target.id == 'btnFs') return; if (document.fullscreenElement === null) { let x = e.pageX; if (x < paOffset) x = paOffset; x = x - paOffset; if (x + sonSize >= paWidth) x = paWidth - sonSize; btnplay.style.cssText += `left: ${x}px;`; vid.style.cssText += `left: ${x - 150}px;`; } else { let xx = e.offsetX || e.layerX; if (xx + sonSize > bodyWidth) xx -= sonSize; btnplay.style.cssText += `left: ${xx}px;`; vid.style.cssText += `left: ${xx - 150}px;`; } }, 400);
};
})();
</script>
【说明】
本帖,全屏模式下,鼠标移动至全屏控制按钮并悬停0.4秒时,不再影响播放按钮对鼠标指针的响应。因为全屏资源有更新,之前访问过《红色》等帖的朋友,需要硬刷新(按 Ctrl+F5)才能看到效果。之前发布的类似帖子未做修改。 |