修复进度条消失的问题
This commit is contained in:
@@ -328,6 +328,23 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
seekBarTranscode.style.width = `${safePercent}%`;
|
seekBarTranscode.style.width = `${safePercent}%`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const syncVideoDurationFromPlayer = () => {
|
||||||
|
if (!videoPlayer) return false;
|
||||||
|
const nextDuration = Number.isFinite(videoPlayer.duration) && videoPlayer.duration > 0
|
||||||
|
? videoPlayer.duration
|
||||||
|
: 0;
|
||||||
|
if (nextDuration <= 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
videoDuration = nextDuration;
|
||||||
|
if (seekTotalTime) {
|
||||||
|
seekTotalTime.textContent = formatTime(videoDuration);
|
||||||
|
}
|
||||||
|
showSeekBar();
|
||||||
|
updateSeekBarPosition(seekOffset + (videoPlayer.currentTime || 0));
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
const showCustomControls = () => {
|
const showCustomControls = () => {
|
||||||
if (customControls) {
|
if (customControls) {
|
||||||
customControls.classList.remove('hidden');
|
customControls.classList.remove('hidden');
|
||||||
@@ -400,6 +417,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
if (seekTotalTime) seekTotalTime.textContent = formatTime(videoDuration);
|
if (seekTotalTime) seekTotalTime.textContent = formatTime(videoDuration);
|
||||||
showSeekBar();
|
showSeekBar();
|
||||||
updateSeekBarPosition(seekOffset + (videoPlayer.currentTime || 0));
|
updateSeekBarPosition(seekOffset + (videoPlayer.currentTime || 0));
|
||||||
|
} else if (message.type === 'duration') {
|
||||||
|
syncVideoDurationFromPlayer();
|
||||||
}
|
}
|
||||||
if (message.type === 'progress') {
|
if (message.type === 'progress') {
|
||||||
handleProgress(message.progress);
|
handleProgress(message.progress);
|
||||||
@@ -530,6 +549,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
lastAbsolutePlaybackTime = absoluteTime;
|
lastAbsolutePlaybackTime = absoluteTime;
|
||||||
updateSeekBarPosition(absoluteTime);
|
updateSeekBarPosition(absoluteTime);
|
||||||
});
|
});
|
||||||
|
videoPlayer.addEventListener('loadedmetadata', syncVideoDurationFromPlayer);
|
||||||
|
videoPlayer.addEventListener('durationchange', syncVideoDurationFromPlayer);
|
||||||
|
|
||||||
videoPlayer.addEventListener('play', () => {
|
videoPlayer.addEventListener('play', () => {
|
||||||
updatePlayControls();
|
updatePlayControls();
|
||||||
@@ -1217,6 +1238,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
videoPlayer.src = streamUrl;
|
videoPlayer.src = streamUrl;
|
||||||
videoPlayer.load();
|
videoPlayer.load();
|
||||||
videoPlayer.addEventListener('loadedmetadata', () => {
|
videoPlayer.addEventListener('loadedmetadata', () => {
|
||||||
|
syncVideoDurationFromPlayer();
|
||||||
transcodingOverlay.classList.add('hidden');
|
transcodingOverlay.classList.add('hidden');
|
||||||
videoPlayer.classList.remove('hidden');
|
videoPlayer.classList.remove('hidden');
|
||||||
isStreamActive = true;
|
isStreamActive = true;
|
||||||
@@ -1303,6 +1325,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
showSeekBar();
|
showSeekBar();
|
||||||
showCustomControls();
|
showCustomControls();
|
||||||
videoPlayer.addEventListener('loadedmetadata', () => {
|
videoPlayer.addEventListener('loadedmetadata', () => {
|
||||||
|
syncVideoDurationFromPlayer();
|
||||||
updateSeekBarPosition(seekOffset);
|
updateSeekBarPosition(seekOffset);
|
||||||
updatePlayControls();
|
updatePlayControls();
|
||||||
updateVolumeControls();
|
updateVolumeControls();
|
||||||
|
|||||||
Reference in New Issue
Block a user