请教夕阳老师:直发代码为何此贴不显示呢?如何实现全屏?谢谢[已解决]
本帖最后由 杨帆 于 2024-12-12 12:54 编辑 <br /><br /><div style=""><style></div><div style="">@import url(https://file.uhsea.com/2403/f45f79bba93cd62f8603eae6fa88eb78YS.css);</div><div style="">:root{--rState:running;--w:1400px;--h:800px;}</div><div style=""><br></div><div style="">#fullscreen { position: absolute; top:5%; left:83%;color:#ffffff; filter:drop-shadow( 1px 1px 1px #000000);font: normal 2.2em 华文新魏; opacity: 0.8; cursor: pointer; z-index: 5}</div><div style=""><br></div><div style=""><br></div><div style="">.lrcShow{font:bold 2.4em 楷体,楷体_GD2312,sans-serif;pointer-events:none;left:20%;bottom:0px;filter:drop-shadow(1px 0px 0px white)drop-shadow(0px 1px 0px white)drop-shadow(-1px 0px 0px white)drop-shadow(0px -1px 0px white);z-index:4;}</div><div style="">.lrcShow::before{color:hsl(0,80%,80%);}</div><div style="">#outBlk{position:relative;width:var(--w);height:var(--h);background:#000000 url(https://pic.imgdb.cn/item/65bf0270871b83018a3ad9aa.jpg)no-repeat center / cover;overflow:hidden;margin: 130px 0 30px calc(50% - 780px);box-shadow:4px 4px 10px #000;}</div><div style="">zxx-slide{width:var(--w);height:var(--h);position:absolute;z-index:1;}</div><div style="">.zxx-slide-a{position:absolute;cursor:default;pointer-events:none;}</div><div style="">.zxx-slide-a.in{z-index:2;animation-duration:2s;animation-name:brightnessIn;transition:1s;}</div><div style="">.zxx-slide-img{width:var(--w);height:var(--h);}</div><div style="">@keyframes brightnessIn{0%{transform:scale(0.1);opacity:0;}10%{transform:scale(0.5);opacity:1;}100%{transform:scale(1)}}</div><div style="">#processMeter{position:absolute;right:20px;bottom:10px;width:200px;height:100px;cursor:pointer;z-index:3;}</div><div style="">#rPlayer{transform-origin:50%;animation:rot 5s linear infinite var(--rState);}</div><div style="">@keyframes rot{to{transform: rotate(1turn)}}</div><div style=""></style></div><div style=""><div id="outBlk"></div><div style=""><br></div><div style=""><span id="fullscreen">全屏观赏</span></div><div style=""><br></div><div style=""><br></div><div style=""> <zxx-slide></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span><svg stroke-width="5" viewBox="0 0 200 100" id="processMeter"></span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span><!-- 背景圆形 --></span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span><path id='bgc' d="M 100 5 A 95 45 0 0 1 100 95 A 95 45 0 0 1 100 5" stroke="#ebeef5" fill="none" ></path></span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span><!-- 进度条 --></span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span><path</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span> class="process-circle"</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span> d="M 100 5 A 95 45 0 0 1 100 95 A 95 45 0 0 1 100 5"</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span> stroke="darkred"</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span> fill="none"</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span> stroke-dasharray="455"</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span> stroke-dashoffset="455"</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>></path></span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span><defs></span></div><div style=""> <span style="white-space:pre"> </span><clipPath id="clip"></div><div style=""> <span style="white-space:pre"> </span><circle cx="100" cy="50" r="41" /></div><div style=""> <span style="white-space:pre"> </span></clilpPath></div><div style=""> </defs></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span><image xlink:href="https://pic.imgdb.cn/item/65b75c8f871b83018a83e1c1.png" width="100" height='100' x="50" y="0" id="rPlayer" clip-path="url(#clip)" preserveAspectRatio="none" /></span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span><text x="85%" y="50%" stroke="lightgray" text-anchor="middle" dominant-baseline="middle" stroke-width="2" style="font-size:13px;" id="durTime"> </text></span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span><text x="15%" y="50%" stroke="lightgray" text-anchor="middle" dominant-baseline="middle" stroke-width="2" style="font-size:13px;" id="curTime"> </text></span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span></svg></zxx-slide><span style="white-space:pre"> </span></span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span><div class="lrcShow" data-lrc="碧水蓝天" >碧水蓝天</div></span></div><div style=""></div></div><div style=""><br></div><div style=""><script></div><div style=""><br></div><div style=""> const processCircle = document.querySelector('.process-circle');</div><div style=""> // 获取圆的周长</div><div style=""> const circumference = processCircle.getTotalLength();</div><div style=""> // 把周长赋值给 strokeDasharray</div><div style=""> processCircle.style.strokeDasharray = circumference;</div><div style=""><br></div><div style=""> function setProcessCircle(percent = 0) {</div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>// 动态计算 offset 赋值给 strokeDashoffset</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>// 为了支持 percent = 0 | '0%',所以使用 parseInt 转换</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>processCircle.style.strokeDashoffset =</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span> circumference * (1 - parseInt(percent) / 100)</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>}</span></div><div style=""><span style="white-space: pre; white-space: normal;"> </span></div><div style="">var sf0 = document.createElement('script');</div><div style="">sf0.type = 'text/javascript';</div><div style="">sf0.src = "https://file.uhsea.com/2410/739c572b5176f670f350463cf9ade957QB.js";</div><div style="">sf0.charset = "utf-8";</div><div style="">document.body.appendChild(sf0);</div><div style=""><br></div><div style="">sf0.onload = () => {</div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>let circlePoints = [];</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>let bgcLen = bgc.getTotalLength();</span></div><div style=""><span style="white-space: pre; white-space: normal;"> </span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>for(let i = 0; i < bgcLen; i++)<span style="white-space:pre"> </span>{</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>circlePoints.push(bgc.getPointAtLength(i));</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>}</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>console.log(circlePoints);</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>let lrctxt = `</span></div><div style=""></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>`;</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>let opts = {</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>lrcTxt:lrctxt,</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>audioURL:"https://www.joy127.com/url/109961.mp3",</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>}</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>let player = new lrcPlayerY(opts);</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>//console.log(player.lrcVec);</span></div><div style="">let pics = [</div><div style="">"https://pic.imgdb.cn/item/674d81d5d0e0a243d4dbf77e.gif",</div><div style="">"https://pic.imgdb.cn/item/674d81f8d0e0a243d4dbf7e1.gif",</div><div style="">"https://pic.imgdb.cn/item/674d8215d0e0a243d4dbf830.gif",</div><div style="">"https://pic.imgdb.cn/item/674d822ed0e0a243d4dbf862.gif",</div><div style="">"https://pic.imgdb.cn/item/674d8244d0e0a243d4dbf891.gif",</div><div style="">"https://pic.imgdb.cn/item/674d8258d0e0a243d4dbf8b5.gif",</div><div style="">"https://pic.imgdb.cn/item/674d826dd0e0a243d4dbf8d4.gif",</div><div style="">"https://pic.imgdb.cn/item/674d8282d0e0a243d4dbf8f2.gif",</div><div style="">"https://pic.imgdb.cn/item/674d8295d0e0a243d4dbf916.gif",</div><div style="">"https://pic.imgdb.cn/item/674d82a8d0e0a243d4dbf930.gif",</div><div style="">];</div><div style="">let eleZxxSlides = document.querySelectorAll('zxx-slide');</div><div style="">pics.forEach(pic => {</div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>let aObj = document.createElement('a');</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>aObj.className = 'zxx-slide-a';</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>let imgObj = document.createElement('img');</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>imgObj.src = pic;</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>imgObj.className = 'zxx-slide-img';</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>aObj.appendChild(imgObj);</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>eleZxxSlides.appendChild(aObj);</span></div><div style="">});</div><div style=""> [].slice.call(eleZxxSlides).forEach(function(container) {</div><div style=""> let timerSlide = null;</div><div style=""> let indexSlide = 0;</div><div style=""> container.addEventListener('mouseover', function() {</div><div style=""> clearTimeout(timerSlide);</div><div style=""> });</div><div style=""> container.addEventListener('mouseout', function() {</div><div style=""> clearTimeout(timerSlide);</div><div style=""> funSlide();</div><div style=""> });</div><div style=""> // 对应的元素</div><div style=""> let eleSlides = [].slice.call(container.querySelectorAll('a'));</div><div style=""> let eleButtons = [].slice.call(container.querySelectorAll('button'));</div><div style=""> let funSlide = function() {</div><div style=""> eleSlides.forEach(function(slide, index) {</div><div style=""> if (!player.mObj.paused) {</div><div style=""> if (indexSlide == index) {</div><div style=""> slide.classList.add('in');</div><div style=""> } else if (slide.classList.contains('in')) {</div><div style=""> slide.classList.remove('in');</div><div style=""> }</div><div style=""> }</div><div style=""> });</div><div style=""> timerSlide = setTimeout(function() {</div><div style=""> indexSlide++;</div><div style=""> if (indexSlide == eleSlides.length) {</div><div style=""> indexSlide = 0;</div><div style=""> }</div><div style=""> funSlide();</div><div style=""> }, 12000);</div><div style=""> }</div><div style=""> indexSlide++;</div><div style=""> setTimeout(funSlide, 12000);</div><div style=""> });</div><div style=""><br></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>let formatTime = (time) => {</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>let str = '';</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>let min = parseInt(time / 60);</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>let sec = parseInt(time % 60);</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>return ((min < 10 ? '0'+min:min) + ":" + (sec < 10 ? '0'+sec:sec));</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>};</span></div><div style=""><span style="white-space: pre; white-space: normal;"> </span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>player.mObj.addEventListener('timeupdate', function() {</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>let processValue = player.mObj.currentTime / player.mObj.duration;</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>processCircle.style.strokeDashoffset = circumference * (1 - processValue);</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>durTime.textContent = formatTime(player.mObj.duration);</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>curTime.textContent = formatTime(player.mObj.currentTime);</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>});</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>rPlayer.onclick = () => {</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>player.mObj.paused ? (outBlk.style.setProperty('--rState','running'), player.mObj.play()) : (outBlk.style.setProperty('--rState','paused'), player.mObj.pause());</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>}</span></div><div style=""><br></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>let seeking = false;</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>let moveEventProc = (event)<span style="white-space:pre"> </span>=><span style="white-space:pre"> </span>{</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>if(!seeking)<span style="white-space:pre"> </span>return;</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>let thePoint = 0, minV = 100;</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>circlePoints.forEach((point, idx ) => {</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>let mx = (point.x - event.offsetX), my = (point.y - event.offsetY)</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>let mv = mx*mx + my*my;</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>if(mv < minV)<span style="white-space:pre"> </span>{</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>minV = mv; thePoint = idx;</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>}</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>})</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>let chkVal = thePoint / circumference;</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>let chkTime = player.mObj.duration * chkVal;</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>processCircle.style.strokeDashoffset = circumference * (1 - chkVal);</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>for(i = 0; i < player.lrcVec.length; i++)<span style="white-space:pre"> </span>{</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>if(player.lrcVec.seconds >= chkTime)<span style="white-space:pre"> </span>{</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>//console.log(player.lrcVec.seconds, i);</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>player.idx = i;</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>player.mObj.currentTime = chkTime;</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>break;</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>}</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>};</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>};</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>processCircle.addEventListener("mousemove", (event) => moveEventProc(event));</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>bgc.addEventListener("mousemove", (event) => moveEventProc(event));</span></div><div style=""><span style="white-space: normal;"><span style="white-space:pre"> </span>processCircle.onclick = bgc.onclick = () => seeking = !seeking; <span style="white-space:pre"> </span></span></div><div style="">}</div><div style=""><br></div><div style="">let fs = true;</div><div style=""> fullscreen.onclick = () => {</div><div style=""> fs ? (fullscreen.innerText = '退出全屏',outBlk.requestFullscreen()) : (fullscreen.innerText = '全屏欣赏', document.exitFullscreen());</div><div style=""> fs = !fs;</div><div style=""> };</div><div style=""></script></div><div style="font-style: italic;"><br></div> 本帖最后由 杨帆 于 2024-12-10 23:29 编辑夕阳老师,您好!此贴在本地测试,除了不能实现全屏,其它功能显示正常
此外,此贴以网页发显示正常,以代码直发论坛为何就显示不了呢?
请帮我看看,给予指导!由衷感谢~@夕阳黄昏 我的天,这么长的代码{:4_173:} 本帖最后由 夕阳黄昏 于 2024-12-12 20:29 编辑 <br /><br /><style>
@import url(https://file.uhsea.com/2403/f45f79bba93cd62f8603eae6fa88eb78YS.css);
:root{--rState:running;--w:1400px;--h:800px;--fw:1400px;--fh:800px}
#fullscreen { position: absolute; top:5%; left:83%;color:#ffffff; filter:drop-shadow( 1px 1px 1px #000000);font: normal 2.2em华文新魏; opacity: 0.8; cursor: pointer; z-index: 5}
.lrcShow{font:bold 2.4em 楷体,楷体_GD2312,sans-serif;pointer-events:none;left:20%;bottom:0px;filter:drop-shadow(1px 0px 0px white)drop-shadow(0px 1px 0px white)drop-shadow(-1px 0px 0px white)drop-shadow(0px -1px 0px white);z-index:4;}
.lrcShow::before{color:hsl(0,80%,80%);}
#outBlk{position:relative;width:var(--w);height:var(--h);background:#000000 url(https://pic.imgdb.cn/item/65bf0270871b83018a3ad9aa.jpg)no-repeat center / cover;overflow:hidden;margin: 130px 0 30px calc(50% - 780px);box-shadow:4px 4px 10px #000;}
zxx-slide{width:var(--fw);height:var(--fh);position:absolute;z-index:1;}
.zxx-slide-a{position:absolute;cursor:default;pointer-events:none;}
.zxx-slide-a.in{z-index:2;animation-duration:2s;animation-name:brightnessIn;transition:1s;}
.zxx-slide-img{width:var(--fw);height:var(--fh);}
@keyframes brightnessIn{0%{transform:scale(0.1);opacity:0;}10%{transform:scale(0.5);opacity:1;}100%{transform:scale(1)}}
#processMeter{position:absolute;right:20px;bottom:10px;width:200px;height:100px;cursor:pointer;z-index:33;}
#rPlayer{transform-origin:50%;animation:rot 5s linear infinite var(--rState);}
@keyframes rot{to{transform: rotate(1turn)}}
</style>
<div id="outBlk">
<span id="fullscreen">全屏观赏</span>
<zxx-slide></zxx-slide>
<svg stroke-width="5" viewBox="0 0 200 100" id="processMeter">
<!-- 背景圆形 -->
<path id='bgc' d="M 100 5 A 95 45 0 0 1 100 95 A 95 45 0 0 1 100 5" stroke="#ebeef5"fill="none" ></path>
<!-- 进度条 -->
<path
class="process-circle"
d="M 100 5 A 95 45 0 0 1 100 95 A 95 45 0 0 1 100 5"
stroke="darkred"
fill="none"
stroke-dasharray="455"
stroke-dashoffset="455"
></path>
<defs>
<clipPath id="clip">
<circle cx="100" cy="50" r="41" />
</clilpPath>
</defs>
<image xlink:href="https://pic.imgdb.cn/item/65b75c8f871b83018a83e1c1.png" width="100" height='100' x="50" y="0" id="rPlayer" clip-path="url(#clip)" preserveAspectRatio="none" />
<text x="85%" y="50%" stroke="lightgray" text-anchor="middle" dominant-baseline="middle" stroke-width="2" style="font-size:13px;" id="durTime"> </text>
<text x="15%" y="50%" stroke="lightgray" text-anchor="middle" dominant-baseline="middle" stroke-width="2" style="font-size:13px;" id="curTime"> </text>
</svg>
<div class="lrcShow" data-lrc="碧水蓝天" >碧水蓝天</div>
</div>
<script>
const processCircle = document.querySelector('.process-circle');
// 获取圆的周长
const circumference = processCircle.getTotalLength();
// 把周长赋值给 strokeDasharray
processCircle.style.strokeDasharray = circumference;
function setProcessCircle(percent = 0) {
// 动态计算 offset 赋值给 strokeDashoffset
// 为了支持 percent = 0 | '0%',所以使用 parseInt 转换
processCircle.style.strokeDashoffset =
circumference * (1 - parseInt(percent) / 100)
}
var sf0 = document.createElement('script');
sf0.type = 'text/javascript';
sf0.src = "https://file.uhsea.com/2410/739c572b5176f670f350463cf9ade957QB.js";
sf0.charset = "utf-8";
document.body.appendChild(sf0);
sf0.onload = () => {
let circlePoints = [];
let bgcLen = bgc.getTotalLength();
for(let i = 0; i < bgcLen; i++) {
circlePoints.push(bgc.getPointAtLength(i));
}
console.log(circlePoints);
let lrctxt = `
`;
let opts = {
lrcTxt:lrctxt,
audioURL:"https://www.joy127.com/url/109961.mp3",
}
let player = new lrcPlayerY(opts);
//console.log(player.lrcVec);
let pics = [
"https://pic.imgdb.cn/item/674d81d5d0e0a243d4dbf77e.gif",
"https://pic.imgdb.cn/item/674d81f8d0e0a243d4dbf7e1.gif",
"https://pic.imgdb.cn/item/674d8215d0e0a243d4dbf830.gif",
"https://pic.imgdb.cn/item/674d822ed0e0a243d4dbf862.gif",
"https://pic.imgdb.cn/item/674d8244d0e0a243d4dbf891.gif",
"https://pic.imgdb.cn/item/674d8258d0e0a243d4dbf8b5.gif",
"https://pic.imgdb.cn/item/674d826dd0e0a243d4dbf8d4.gif",
"https://pic.imgdb.cn/item/674d8282d0e0a243d4dbf8f2.gif",
"https://pic.imgdb.cn/item/674d8295d0e0a243d4dbf916.gif",
"https://pic.imgdb.cn/item/674d82a8d0e0a243d4dbf930.gif",
];
let eleZxxSlides = document.querySelectorAll('zxx-slide');
pics.forEach(pic => {
let aObj = document.createElement('a');
aObj.className = 'zxx-slide-a';
let imgObj = document.createElement('img');
imgObj.src = pic;
imgObj.className = 'zxx-slide-img';
aObj.appendChild(imgObj);
eleZxxSlides.appendChild(aObj);
});
[].slice.call(eleZxxSlides).forEach(function(container) {
let timerSlide = null;
let indexSlide = 0;
// 对应的元素
let eleSlides = [].slice.call(container.querySelectorAll('a'));
let eleButtons = [].slice.call(container.querySelectorAll('button'));
let funSlide = function() {
eleSlides.forEach(function(slide, index) {
if (!player.mObj.paused) {
if (indexSlide == index) {
slide.classList.add('in');
} else if (slide.classList.contains('in')) {
slide.classList.remove('in');
}
}
});
timerSlide = setTimeout(function() {
indexSlide++;
if (indexSlide == eleSlides.length) {
indexSlide = 0;
}
funSlide();
}, 8000);
}
indexSlide++;
setTimeout(funSlide, 8000);
});
let formatTime = (time) => {
let str = '';
let min = parseInt(time / 60);
let sec = parseInt(time % 60);
return ((min < 10 ? '0'+min:min) + ":" + (sec < 10 ? '0'+sec:sec));
};
player.mObj.addEventListener('timeupdate', function() {
let processValue = player.mObj.currentTime / player.mObj.duration;
processCircle.style.strokeDashoffset = circumference * (1 - processValue);
durTime.textContent = formatTime(player.mObj.duration);
curTime.textContent = formatTime(player.mObj.currentTime);
});
rPlayer.onclick = () => {
player.mObj.paused ? (outBlk.style.setProperty('--rState','running'), player.mObj.play()) : (outBlk.style.setProperty('--rState','paused'), player.mObj.pause());
}
let seeking = false;
let moveEventProc = (event) => {
if(!seeking) return;
let thePoint = 0, minV = 100;
circlePoints.forEach((point, idx ) => {
let mx = (point.x - event.offsetX), my = (point.y - event.offsetY)
let mv = mx*mx + my*my;
if(mv < minV) {
minV = mv; thePoint = idx;
}
})
let chkVal = thePoint / circumference;
let chkTime = player.mObj.duration * chkVal;
processCircle.style.strokeDashoffset = circumference * (1 - chkVal);
for(i = 0; i < player.lrcVec.length; i++) {
if(player.lrcVec.seconds >= chkTime) {
//console.log(player.lrcVec.seconds, i);
player.idx = i;
player.mObj.currentTime = chkTime;
break;
}
};
};
processCircle.addEventListener("mousemove", (event) => moveEventProc(event));
bgc.addEventListener("mousemove", (event) => moveEventProc(event));
processCircle.onclick = bgc.onclick = () => seeking = !seeking;
}
let fs = true;
fullscreen.onclick = () => {
fs ? (fullscreen.innerText = '退出全屏',outBlk.requestFullscreen()) : (fullscreen.innerText = '全屏欣赏', document.exitFullscreen());
if(fs) {outBlk.style.setProperty('--fw',window.screen.width + 'px');outBlk.style.setProperty('--fh',window.screen.height + 'px');}
fs = !fs;
};
</script> 4#一字没改 夕阳黄昏 发表于 2024-12-11 06:21
4#一字没改
夕阳老师威武!请看看,如何实现全屏呢?谢谢@夕阳黄昏 红影 发表于 2024-12-10 23:47
我的天,这么长的代码
谢谢影子关注与支持!也许有些代码多余,不清楚其逻辑关系,未敢妄动 杨帆 发表于 2024-12-11 11:20
夕阳老师威武!请看看,如何实现全屏呢?谢谢@夕阳黄昏
全屏我不熟悉,不过看其他有这功能的帖子也只是背景全屏而附在上面的其他元素并没受到影响。 杨帆 发表于 2024-12-11 12:20
谢谢影子关注与支持!也许有些代码多余,不清楚其逻辑关系,未敢妄动
不是,我是说一多了,我就看迷糊了,我学习代码也是半瓶水,看到多的就怕了{:4_173:} 本帖最后由 杨帆 于 2024-12-11 13:54 编辑
夕阳黄昏 发表于 2024-12-11 13:13
全屏我不熟悉,不过看其他有这功能的帖子也只是背景全屏而附在上面的其他元素并没受到影响。
辛苦了,夕阳老师!
上一个贴也是图片轮播,在您的指导下终于实现了全屏
这一个贴,我相信您有办法让它也实现全屏{:4_191:}
牧羊人的一天
https://www.huachaowang.com/foru ... =79819&fromuid=7894
(出处: 花潮论坛)
红影 发表于 2024-12-11 13:18
不是,我是说一多了,我就看迷糊了,我学习代码也是半瓶水,看到多的就怕了
哈哈,似懂非懂之际,代码多了也挺有趣呀,但不用怕,我们论坛有这么多大师呢{:4_199:} 杨帆 发表于 2024-12-11 13:22
辛苦了,夕阳老师!
上一个贴也是图片轮播,在您的指导下终于实现了全屏
我真做不到,把这帖的图片换到那帖也不行 夕阳黄昏 发表于 2024-12-11 16:08
我真做不到,把这帖的图片换到那帖也不行
谢谢夕阳老师,您辛苦了!
我只是好奇,不急,等老师慢慢研究吧{:4_190:} 夕阳黄昏 发表于 2024-12-11 16:08
我真做不到,把这帖的图片换到那帖也不行
谢谢夕阳老师!此贴的基础代码是您的《红枫叶》,或许与图片有关呢?
https://www.huachaowang.com/forum.php?mod=viewthread&tid=79448&fromuid=7894
(出处: 花潮论坛)
杨帆 发表于 2024-12-11 16:26
谢谢夕阳老师!此贴的基础代码是您的《红枫叶》,或许与图片有关呢?
https://www.huachaowang.com/fo ...
对全屏代码不熟悉,我的所有帖子都没有用过全屏代码,到底哪出了问题搞不清楚。 本帖最后由 杨帆 于 2024-12-11 19:12 编辑
谢谢夕阳老师!全屏代码也挺有趣呢,老师您有空了不妨研究一下呗@夕阳黄昏 杨帆 发表于 2024-12-11 13:30
哈哈,似懂非懂之际,代码多了也挺有趣呀,但不用怕,我们论坛有这么多大师呢
是的,只能麻烦大师们了{:4_173:} 杨帆 发表于 2024-12-11 19:11
谢谢夕阳老师!全屏代码也挺有趣呢,老师您有空了不妨研究一下呗@夕阳黄昏
再试试
<style>
@import url(https://file.uhsea.com/2403/f45f79bba93cd62f8603eae6fa88eb78YS.css);
:root{--rState:running;--w:1400px;--h:800px;--fw:1400px;--fh:800px}
#fullscreen { position: absolute; top:5%; left:83%;color:#ffffff; filter:drop-shadow( 1px 1px 1px #000000);font: normal 2.2em华文新魏; opacity: 0.8; cursor: pointer; z-index: 5}
.lrcShow{font:bold 2.4em 楷体,楷体_GD2312,sans-serif;pointer-events:none;left:20%;bottom:0px;filter:drop-shadow(1px 0px 0px white)drop-shadow(0px 1px 0px white)drop-shadow(-1px 0px 0px white)drop-shadow(0px -1px 0px white);z-index:4;}
.lrcShow::before{color:hsl(0,80%,80%);}
#outBlk{position:relative;width:var(--w);height:var(--h);background:#000000 url(https://pic.imgdb.cn/item/65bf0270871b83018a3ad9aa.jpg)no-repeat center / cover;overflow:hidden;margin: 130px 0 30px calc(50% - 780px);box-shadow:4px 4px 10px #000;}
zxx-slide{width:var(--fw);height:var(--fh);position:absolute;z-index:1;}
.zxx-slide-a{position:absolute;cursor:default;pointer-events:none;}
.zxx-slide-a.in{z-index:2;animation-duration:2s;animation-name:brightnessIn;transition:1s;}
.zxx-slide-img{width:var(--fw);height:var(--fh);}
@keyframes brightnessIn{0%{transform:scale(0.1);opacity:0;}10%{transform:scale(0.5);opacity:1;}100%{transform:scale(1)}}
#processMeter{position:absolute;right:20px;bottom:10px;width:200px;height:100px;cursor:pointer;z-index:33;}
#rPlayer{transform-origin:50%;animation:rot 5s linear infinite var(--rState);}
@keyframes rot{to{transform: rotate(1turn)}}
</style>
<div id="outBlk">
<span id="fullscreen">全屏观赏</span>
<zxx-slide></zxx-slide>
<svg stroke-width="5" viewBox="0 0 200 100" id="processMeter">
<!-- 背景圆形 -->
<path id='bgc' d="M 100 5 A 95 45 0 0 1 100 95 A 95 45 0 0 1 100 5" stroke="#ebeef5"fill="none" ></path>
<!-- 进度条 -->
<path
class="process-circle"
d="M 100 5 A 95 45 0 0 1 100 95 A 95 45 0 0 1 100 5"
stroke="darkred"
fill="none"
stroke-dasharray="455"
stroke-dashoffset="455"
></path>
<defs>
<clipPath id="clip">
<circle cx="100" cy="50" r="41" />
</clilpPath>
</defs>
<image xlink:href="https://pic.imgdb.cn/item/65b75c8f871b83018a83e1c1.png" width="100" height='100' x="50" y="0" id="rPlayer" clip-path="url(#clip)" preserveAspectRatio="none" />
<text x="85%" y="50%" stroke="lightgray" text-anchor="middle" dominant-baseline="middle" stroke-width="2" style="font-size:13px;" id="durTime"> </text>
<text x="15%" y="50%" stroke="lightgray" text-anchor="middle" dominant-baseline="middle" stroke-width="2" style="font-size:13px;" id="curTime"> </text>
</svg>
<div class="lrcShow" data-lrc="碧水蓝天" >碧水蓝天</div>
</div>
<script>
const processCircle = document.querySelector('.process-circle');
// 获取圆的周长
const circumference = processCircle.getTotalLength();
// 把周长赋值给 strokeDasharray
processCircle.style.strokeDasharray = circumference;
function setProcessCircle(percent = 0) {
// 动态计算 offset 赋值给 strokeDashoffset
// 为了支持 percent = 0 | '0%',所以使用 parseInt 转换
processCircle.style.strokeDashoffset =
circumference * (1 - parseInt(percent) / 100)
}
var sf0 = document.createElement('script');
sf0.type = 'text/javascript';
sf0.src = "https://file.uhsea.com/2410/739c572b5176f670f350463cf9ade957QB.js";
sf0.charset = "utf-8";
document.body.appendChild(sf0);
sf0.onload = () => {
let circlePoints = [];
let bgcLen = bgc.getTotalLength();
for(let i = 0; i < bgcLen; i++) {
circlePoints.push(bgc.getPointAtLength(i));
}
console.log(circlePoints);
let lrctxt = `
`;
let opts = {
lrcTxt:lrctxt,
audioURL:"https://www.joy127.com/url/109961.mp3",
}
let player = new lrcPlayerY(opts);
//console.log(player.lrcVec);
let pics = [
"https://pic.imgdb.cn/item/674d81d5d0e0a243d4dbf77e.gif",
"https://pic.imgdb.cn/item/674d81f8d0e0a243d4dbf7e1.gif",
"https://pic.imgdb.cn/item/674d8215d0e0a243d4dbf830.gif",
"https://pic.imgdb.cn/item/674d822ed0e0a243d4dbf862.gif",
"https://pic.imgdb.cn/item/674d8244d0e0a243d4dbf891.gif",
"https://pic.imgdb.cn/item/674d8258d0e0a243d4dbf8b5.gif",
"https://pic.imgdb.cn/item/674d826dd0e0a243d4dbf8d4.gif",
"https://pic.imgdb.cn/item/674d8282d0e0a243d4dbf8f2.gif",
"https://pic.imgdb.cn/item/674d8295d0e0a243d4dbf916.gif",
"https://pic.imgdb.cn/item/674d82a8d0e0a243d4dbf930.gif",
];
let eleZxxSlides = document.querySelectorAll('zxx-slide');
pics.forEach(pic => {
let aObj = document.createElement('a');
aObj.className = 'zxx-slide-a';
let imgObj = document.createElement('img');
imgObj.src = pic;
imgObj.className = 'zxx-slide-img';
aObj.appendChild(imgObj);
eleZxxSlides.appendChild(aObj);
});
[].slice.call(eleZxxSlides).forEach(function(container) {
let timerSlide = null;
let indexSlide = 0;
container.addEventListener('mouseover', function() {
clearTimeout(timerSlide);
});
container.addEventListener('mouseout', function() {
clearTimeout(timerSlide);
funSlide();
});
// 对应的元素
let eleSlides = [].slice.call(container.querySelectorAll('a'));
let eleButtons = [].slice.call(container.querySelectorAll('button'));
let funSlide = function() {
eleSlides.forEach(function(slide, index) {
if (!player.mObj.paused) {
if (indexSlide == index) {
slide.classList.add('in');
} else if (slide.classList.contains('in')) {
slide.classList.remove('in');
}
}
});
timerSlide = setTimeout(function() {
indexSlide++;
if (indexSlide == eleSlides.length) {
indexSlide = 0;
}
funSlide();
}, 12000);
}
indexSlide++;
setTimeout(funSlide, 12000);
});
let formatTime = (time) => {
let str = '';
let min = parseInt(time / 60);
let sec = parseInt(time % 60);
return ((min < 10 ? '0'+min:min) + ":" + (sec < 10 ? '0'+sec:sec));
};
player.mObj.addEventListener('timeupdate', function() {
let processValue = player.mObj.currentTime / player.mObj.duration;
processCircle.style.strokeDashoffset = circumference * (1 - processValue);
durTime.textContent = formatTime(player.mObj.duration);
curTime.textContent = formatTime(player.mObj.currentTime);
});
rPlayer.onclick = () => {
player.mObj.paused ? (outBlk.style.setProperty('--rState','running'), player.mObj.play()) : (outBlk.style.setProperty('--rState','paused'), player.mObj.pause());
}
let seeking = false;
let moveEventProc = (event) => {
if(!seeking) return;
let thePoint = 0, minV = 100;
circlePoints.forEach((point, idx ) => {
let mx = (point.x - event.offsetX), my = (point.y - event.offsetY)
let mv = mx*mx + my*my;
if(mv < minV) {
minV = mv; thePoint = idx;
}
})
let chkVal = thePoint / circumference;
let chkTime = player.mObj.duration * chkVal;
processCircle.style.strokeDashoffset = circumference * (1 - chkVal);
for(i = 0; i < player.lrcVec.length; i++) {
if(player.lrcVec.seconds >= chkTime) {
//console.log(player.lrcVec.seconds, i);
player.idx = i;
player.mObj.currentTime = chkTime;
break;
}
};
};
processCircle.addEventListener("mousemove", (event) => moveEventProc(event));
bgc.addEventListener("mousemove", (event) => moveEventProc(event));
processCircle.onclick = bgc.onclick = () => seeking = !seeking;
}
let fs = true;
fullscreen.onclick = () => {
fs ? (fullscreen.innerText = '退出全屏',outBlk.requestFullscreen()) : (fullscreen.innerText = '全屏欣赏', document.exitFullscreen());
if(fs) {outBlk.style.setProperty('--fw',window.screen.width + 'px');outBlk.style.setProperty('--fh',window.screen.height + 'px');}
fs = !fs;
};
</script> 红影 发表于 2024-12-11 20:26
是的,只能麻烦大师们了
赞同~大师们是花潮的脊梁,是引领论坛高质量发展砥砺前行的源动力,向大师们致敬!
夕阳黄昏 发表于 2024-12-12 10:37
再试试
感恩夕阳老师,您太厉害了!@夕阳黄昏
为攻无不克、战无不胜的夕阳老师点一个大大的赞{:5_116:}{:5_116:}{:5_116:}
页:
[1]
2