Removed duplicate error handlers
This commit is contained in:
@@ -140,17 +140,28 @@ class VideoPlayer {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (data.type === Hls.ErrorTypes.MEDIA_ERROR) {
|
} else if (data.type === Hls.ErrorTypes.MEDIA_ERROR) {
|
||||||
// Non-fatal media error - try to recover (handles audio codec issues)
|
// Non-fatal media error - try to recover with cooldown to prevent loops
|
||||||
console.log('Non-fatal media error:', data.details);
|
const now = Date.now();
|
||||||
this.hls.recoverMediaError();
|
const timeSinceLastRecovery = now - (this.lastRecoveryAttempt || 0);
|
||||||
// If fragParsingError, also seek forward slightly to skip corrupted segment
|
|
||||||
if (data.details === 'fragParsingError' && !this.video.paused && this.video.currentTime > 0) {
|
// Only attempt recovery if more than 2 seconds since last attempt
|
||||||
console.log('[HLS] Seeking past corrupted segment...');
|
if (timeSinceLastRecovery > 2000) {
|
||||||
setTimeout(() => {
|
console.log('Non-fatal media error:', data.details, '- attempting recovery');
|
||||||
if (this.video && !this.video.paused) {
|
this.lastRecoveryAttempt = now;
|
||||||
this.video.currentTime += 0.5;
|
this.hls.recoverMediaError();
|
||||||
}
|
|
||||||
}, 100);
|
// If fragParsingError, also seek forward slightly to skip corrupted segment
|
||||||
|
if (data.details === 'fragParsingError' && !this.video.paused && this.video.currentTime > 0) {
|
||||||
|
console.log('[HLS] Seeking past corrupted segment...');
|
||||||
|
setTimeout(() => {
|
||||||
|
if (this.video && !this.video.paused) {
|
||||||
|
this.video.currentTime += 1;
|
||||||
|
}
|
||||||
|
}, 200);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Too many errors in quick succession - log but don't spam recovery
|
||||||
|
console.log('Non-fatal media error (cooldown):', data.details);
|
||||||
}
|
}
|
||||||
} else if (data.details === 'bufferAppendError') {
|
} else if (data.details === 'bufferAppendError') {
|
||||||
// Buffer errors during ad transitions - try recovery
|
// Buffer errors during ad transitions - try recovery
|
||||||
@@ -336,21 +347,18 @@ class VideoPlayer {
|
|||||||
this.hls.loadSource(this.getProxiedUrl(this.currentUrl));
|
this.hls.loadSource(this.getProxiedUrl(this.currentUrl));
|
||||||
this.hls.startLoad();
|
this.hls.startLoad();
|
||||||
} else if (data.type === Hls.ErrorTypes.MEDIA_ERROR) {
|
} else if (data.type === Hls.ErrorTypes.MEDIA_ERROR) {
|
||||||
console.log('Media error, attempting recovery...');
|
// Fatal media error - try recovery with cooldown
|
||||||
this.hls.recoverMediaError();
|
const now = Date.now();
|
||||||
|
if (now - (this.lastRecoveryAttempt || 0) > 2000) {
|
||||||
|
console.log('Fatal media error, attempting recovery...');
|
||||||
|
this.lastRecoveryAttempt = now;
|
||||||
|
this.hls.recoverMediaError();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
console.error('Fatal HLS error:', data);
|
console.error('Fatal HLS error:', data);
|
||||||
}
|
}
|
||||||
} else if (data.type === Hls.ErrorTypes.MEDIA_ERROR) {
|
} else if (data.type === Hls.ErrorTypes.MEDIA_ERROR) {
|
||||||
// Non-fatal media error - handle specific cases
|
// Non-fatal media error - already handled in init(), skip duplicate handling
|
||||||
console.log('Non-fatal media error:', data.details);
|
|
||||||
if (data.details === 'bufferStalledError') {
|
|
||||||
// Buffer stalled - seek forward to unstick
|
|
||||||
console.log('[HLS] Buffer stalled, seeking to recover...');
|
|
||||||
if (!this.video.paused && this.video.currentTime > 0) {
|
|
||||||
this.video.currentTime += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user