以下代码,直接放到小工具里就可以了,目前测试API还是有效的,大约8000个视频,效果如下图右侧:
<div class="sidebar-random-video"> <h4 class="gradient-title">随机小姐姐小工具</h4> <div class="video-container"> <video class="video" id="player" src="https://scyidc.cn/API/rmtmsp/api.php/video.php?_t=2072366287" controls="controls" webkit-playsinline="" playsinline="" page-gesture="true" show-center-play-btn="true" show-play-btn="false" frameborder="no" border="0" width="100%" autoplay="autoplay"></video> </div> <div class="button-container" style="display: flex;justify-content: space-around;"> <button class="refresh-button" onclick="refreshVideo()">下一个</button> <button id="autoPlayButton" class="auto-play-on" onclick="toggleAutoPlay()">自动播放: 开</button> <button id="continuousPlayButton" class="continuous-play-on" onclick="toggleContinuousPlay()">连续播放: 开</button></div> </div> <script>const video = document.getElementById('player'); const autoPlayButton = document.getElementById('autoPlayButton'); const continuousPlayButton = document.getElementById('continuousPlayButton'); let isAutoPlay = true; let isContinuousPlay = true; function refreshVideo() { const randomParam = '1567691505'; video.src = `https: //scyidc.cn/API/rmtmsp/api.php/video.php?_t=${randomParam}`; video.load(); if (isAutoPlay) { video.play(). catch(error = >{ console.error('播放视频出错:', error); }); } } function toggleAutoPlay() { isAutoPlay = !isAutoPlay; if (isAutoPlay) { video.play(). catch(error = >{ console.error('自动播放开启时播放视频出错:', error); }); autoPlayButton.textContent = '自动播放: 开'; autoPlayButton.classList.remove('auto-play-off'); autoPlayButton.classList.add('auto-play-on'); } else { video.pause(); autoPlayButton.textContent = '自动播放: 关'; autoPlayButton.classList.remove('auto-play-on'); autoPlayButton.classList.add('auto-play-off'); } } function toggleContinuousPlay() { isContinuousPlay = !isContinuousPlay; if (isContinuousPlay) { video.addEventListener('ended', replayVideo); continuousPlayButton.textContent = '连续播放: 开'; continuousPlayButton.classList.remove('continuous-play-off'); continuousPlayButton.classList.add('continuous-play-on'); } else { video.removeEventListener('ended', replayVideo); continuousPlayButton.textContent = '连续播放: 关'; continuousPlayButton.classList.remove('continuous-play-on'); continuousPlayButton.classList.add('continuous-play-off'); } } function replayVideo() { refreshVideo(); }</script>
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
评论(0)