修复下载进度的错误问题
This commit is contained in:
@@ -899,6 +899,15 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
}
|
}
|
||||||
resetPhases();
|
resetPhases();
|
||||||
|
|
||||||
|
// Reset subtitle selector before subscribing to ensure we use the base key for source download
|
||||||
|
if (subtitleSelector) {
|
||||||
|
subtitleSelector.innerHTML = '<option value="-1">无字幕</option>';
|
||||||
|
subtitleSelector.value = "-1";
|
||||||
|
}
|
||||||
|
if (subtitlePanel) {
|
||||||
|
subtitlePanel.classList.add('hidden');
|
||||||
|
}
|
||||||
|
|
||||||
selectedKey = key;
|
selectedKey = key;
|
||||||
currentVideoKey = key;
|
currentVideoKey = key;
|
||||||
subscribeToKey(key);
|
subscribeToKey(key);
|
||||||
@@ -906,6 +915,12 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
nowPlaying.classList.remove('hidden');
|
nowPlaying.classList.remove('hidden');
|
||||||
currentVideoTitle.textContent = key.split('/').pop();
|
currentVideoTitle.textContent = key.split('/').pop();
|
||||||
|
|
||||||
|
// If download is needed, show the overlay so the user sees the progress
|
||||||
|
if (!hasDownloadCache) {
|
||||||
|
transcodingOverlay.classList.remove('hidden');
|
||||||
|
showDownloadPhase();
|
||||||
|
}
|
||||||
|
|
||||||
// Fetch subtitle metadata
|
// Fetch subtitle metadata
|
||||||
fetchVideoMetadata(selectedBucket, key);
|
fetchVideoMetadata(selectedBucket, key);
|
||||||
};
|
};
|
||||||
|
|||||||
25
server.js
25
server.js
@@ -192,12 +192,29 @@ const removeWsClient = (ws) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const broadcastWs = (key, payload) => {
|
const broadcastWs = (key, payload) => {
|
||||||
|
// Broadcast to the specific room
|
||||||
const clients = wsSubscriptions.get(key);
|
const clients = wsSubscriptions.get(key);
|
||||||
if (!clients) return;
|
|
||||||
const message = JSON.stringify(payload);
|
const message = JSON.stringify(payload);
|
||||||
for (const client of clients) {
|
if (clients) {
|
||||||
if (client.readyState === WebSocket.OPEN) {
|
for (const client of clients) {
|
||||||
client.send(message);
|
if (client.readyState === WebSocket.OPEN) {
|
||||||
|
client.send(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If this is a base key (not a sub-key), also broadcast to all its sub-keys
|
||||||
|
if (!key.includes('-sub')) {
|
||||||
|
for (const [subKey, subClients] of wsSubscriptions.entries()) {
|
||||||
|
if (subKey.startsWith(`${key}-sub`)) {
|
||||||
|
for (const client of subClients) {
|
||||||
|
if (client.readyState === WebSocket.OPEN) {
|
||||||
|
// We need to keep the payload key matching the room key for filtering on the client side
|
||||||
|
const subPayload = { ...payload, key: subKey };
|
||||||
|
client.send(JSON.stringify(subPayload));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user