修复问题6

This commit is contained in:
CN-JS-HuiBai
2026-04-03 23:39:51 +08:00
parent 500cf03652
commit 3fa6e4ef4d
2 changed files with 25 additions and 1 deletions

View File

@@ -94,6 +94,7 @@ document.addEventListener('DOMContentLoaded', () => {
let managedSubtitleTracks = [];
let selectedSubtitleTrackId = 'off';
let pendingAutoPlayAfterDownload = false;
let lastPolledProgressSignature = '';
if (videoPlayer) {
videoPlayer.controls = false;
@@ -1377,10 +1378,22 @@ document.addEventListener('DOMContentLoaded', () => {
const pollProgress = async () => {
if (!currentVideoKey) return;
try {
const res = await fetch(`/api/progress?key=${encodeURIComponent(currentVideoKey)}`);
const res = await fetch(`/api/progress?key=${encodeURIComponent(currentVideoKey)}&_=${Date.now()}`, {
cache: 'no-store'
});
if (!res.ok) return;
const data = await res.json();
if (data?.progress) {
const nextSignature = `${data.progress.status}:${typeof data.progress.percent === 'number' ? data.progress.percent : 'na'}`;
if (lastPolledProgressSignature !== nextSignature) {
lastPolledProgressSignature = nextSignature;
console.log('[progress-poll]', {
status: data.progress.status,
percent: data.progress.percent,
downloadedBytes: data.progress.downloadedBytes,
totalBytes: data.progress.totalBytes
});
}
handleProgress(data.progress);
if (typeof data.progress.duration === 'number' && data.progress.duration > 0) {
videoDuration = data.progress.duration;