minor fix to trailer retry logic

This commit is contained in:
chrisk325 2026-03-06 13:32:44 +05:30 committed by GitHub
parent 9dfb3aa474
commit 21e5035c97
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -159,28 +159,18 @@ const TrailerModal: React.FC<TrailerModalProps> = memo(({
const handleVideoError = useCallback((error: any) => { const handleVideoError = useCallback((error: any) => {
logger.error('TrailerModal', 'Video error:', error); logger.error('TrailerModal', 'Video error:', error);
const errorCode = error?.error?.code; if (retryCount < 2) {
const isRetryableError = errorCode === -1102 || errorCode === -1009 || errorCode === -1005; logger.info('TrailerModal', `Re-extracting trailer (attempt ${retryCount + 1}/2)`);
if (isRetryableError && retryCount < 2) {
logger.info('TrailerModal', `Retrying video load (attempt ${retryCount + 1}/2)`);
setRetryCount(prev => prev + 1); setRetryCount(prev => prev + 1);
// Re-run full extraction — don't reload the same bad URL
// Capture current URL before clearing it loadTrailer();
setTrailerUrl(current => {
const urlToRestore = current;
setTimeout(() => {
setTrailerUrl(urlToRestore);
}, 500);
return null; // Clear first to force remount
});
return; return;
} }
logger.error('TrailerModal', 'Video error after retries or non-retryable:', error); logger.error('TrailerModal', 'Video error after retries:', error);
setError('Unable to play trailer. Please try again.'); setError('Unable to play trailer. Please try again.');
setLoading(false); setLoading(false);
}, [retryCount]); }, [retryCount, loadTrailer]);
const handleTrailerEnd = useCallback(() => { const handleTrailerEnd = useCallback(() => {
setIsPlaying(false); setIsPlaying(false);