mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-03-11 17:45:38 +00:00
minor fix to trailer retry logic
This commit is contained in:
parent
9dfb3aa474
commit
21e5035c97
1 changed files with 6 additions and 16 deletions
|
|
@ -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);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue