修复问题6
This commit is contained in:
@@ -94,6 +94,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
let managedSubtitleTracks = [];
|
let managedSubtitleTracks = [];
|
||||||
let selectedSubtitleTrackId = 'off';
|
let selectedSubtitleTrackId = 'off';
|
||||||
let pendingAutoPlayAfterDownload = false;
|
let pendingAutoPlayAfterDownload = false;
|
||||||
|
let lastPolledProgressSignature = '';
|
||||||
|
|
||||||
if (videoPlayer) {
|
if (videoPlayer) {
|
||||||
videoPlayer.controls = false;
|
videoPlayer.controls = false;
|
||||||
@@ -1377,10 +1378,22 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
const pollProgress = async () => {
|
const pollProgress = async () => {
|
||||||
if (!currentVideoKey) return;
|
if (!currentVideoKey) return;
|
||||||
try {
|
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;
|
if (!res.ok) return;
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
if (data?.progress) {
|
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);
|
handleProgress(data.progress);
|
||||||
if (typeof data.progress.duration === 'number' && data.progress.duration > 0) {
|
if (typeof data.progress.duration === 'number' && data.progress.duration > 0) {
|
||||||
videoDuration = data.progress.duration;
|
videoDuration = data.progress.duration;
|
||||||
|
|||||||
11
server.js
11
server.js
@@ -91,6 +91,7 @@ const createS3Client = (credentials) => {
|
|||||||
const progressMap = {};
|
const progressMap = {};
|
||||||
const transcodeProcesses = new Map();
|
const transcodeProcesses = new Map();
|
||||||
const wsSubscriptions = new Map();
|
const wsSubscriptions = new Map();
|
||||||
|
const progressApiLogMap = new Map();
|
||||||
|
|
||||||
const AVAILABLE_VIDEO_ENCODERS = [
|
const AVAILABLE_VIDEO_ENCODERS = [
|
||||||
{ value: 'h264_rkmpp', label: 'h264_rkmpp (RKMPP H.264)' },
|
{ value: 'h264_rkmpp', label: 'h264_rkmpp (RKMPP H.264)' },
|
||||||
@@ -822,6 +823,16 @@ app.get('/api/progress', (req, res) => {
|
|||||||
|
|
||||||
const progressKey = getProgressKey(key);
|
const progressKey = getProgressKey(key);
|
||||||
const progress = progressMap[progressKey] || null;
|
const progress = progressMap[progressKey] || null;
|
||||||
|
const observedState = progress
|
||||||
|
? `${progress.status}:${typeof progress.percent === 'number' ? progress.percent : 'na'}`
|
||||||
|
: 'null';
|
||||||
|
if (progressApiLogMap.get(progressKey) !== observedState) {
|
||||||
|
progressApiLogMap.set(progressKey, observedState);
|
||||||
|
console.log(`[progress-api] key=${key} status=${progress?.status || 'null'} percent=${typeof progress?.percent === 'number' ? progress.percent : 'na'}`);
|
||||||
|
}
|
||||||
|
res.setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, proxy-revalidate');
|
||||||
|
res.setHeader('Pragma', 'no-cache');
|
||||||
|
res.setHeader('Expires', '0');
|
||||||
res.json({ progress });
|
res.json({ progress });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching progress:', error);
|
console.error('Error fetching progress:', error);
|
||||||
|
|||||||
Reference in New Issue
Block a user