一分钟搭建影视站,支持Docker等部署方式
feat: improve video playback progress restoration from local storage
developerd5e3921450d5
diff --git a/player.html b/player.htmlindex 38a195c..638ebb0 100644--- a/player.html+++ b/player.html@@ -501,20 +501,6 @@// 初始化播放器if (videoUrl) {initPlayer(videoUrl, sourceCode);-- // 尝试从URL参数中恢复播放位置- const position = urlParams.get('position');- if (position) {- setTimeout(() => {- if (dp && dp.video) {- const positionNum = parseInt(position);- if (!isNaN(positionNum) && positionNum > 0) {- dp.seek(positionNum);- showPositionRestoreHint(positionNum);- }- }- }, 1500);- }} else {showError('无效的视频链接');}@@ -827,8 +813,28 @@dp.on('loadedmetadata', function() {document.getElementById('loading').style.display = 'none';videoHasEnded = false; // 视频加载时重置结束标志-- // 视频加载完成后重新设置进度条点击监听++ // 新增:尝试从本地存储恢复播放进度+ try {+ const progressKey = 'videoProgress_' + currentVideoUrl;+ const progressStr = localStorage.getItem(progressKey);+ if (progressStr && dp && dp.video && dp.video.duration > 0) {+ const progress = JSON.parse(progressStr);+ if (+ progress &&+ typeof progress.position === 'number' &&+ progress.position > 10 &&+ progress.position < dp.video.duration - 2+ ) {+ dp.seek(progress.position);+ showPositionRestoreHint(progress.position);+ }+ }+ } catch (e) {+ // ignore+ }++ // 视频加载成功后重新设置进度条点击监听setupProgressBarPreciseClicks();// 视频加载成功后,在稍微延迟后将其添加到观看历史@@ -1623,7 +1629,7 @@const icon = document.getElementById('lockIcon');// 切换图标:锁 / 解锁icon.innerHTML = controlsLocked- ? '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d=\"M12 15v2m0-8V7a4 4 0 00-8 0v2m8 0H4v8h16v-8h-4z\"/>'+ ? '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d=\"M12 15v2m0-8V7a4 4 0 00-8 0v2m8 0H4v8h16v-8H6v-6z\"/>': '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d=\"M15 11V7a3 3 0 00-6 0v4m-3 4h12v6H6v-6z\"/>';}</script>