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