mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-03-11 09:35:42 +00:00
Update TrailerModal.tsx
This commit is contained in:
parent
16a9c5c41d
commit
86477b594a
1 changed files with 9 additions and 16 deletions
|
|
@ -159,35 +159,28 @@ const TrailerModal: React.FC<TrailerModalProps> = memo(({
|
|||
const handleVideoError = useCallback((error: any) => {
|
||||
logger.error('TrailerModal', 'Video error:', error);
|
||||
|
||||
// Check if this is a permission/network error that might benefit from retry
|
||||
const errorCode = error?.error?.code;
|
||||
const isRetryableError = errorCode === -1102 || errorCode === -1009 || errorCode === -1005;
|
||||
|
||||
if (isRetryableError && retryCount < 2) {
|
||||
// Silent retry - increment count and try again
|
||||
logger.info('TrailerModal', `Retrying video load (attempt ${retryCount + 1}/2)`);
|
||||
setRetryCount(prev => prev + 1);
|
||||
|
||||
// Small delay before retry to avoid rapid-fire attempts
|
||||
setTimeout(() => {
|
||||
if (videoRef.current) {
|
||||
// Force video to reload by changing the source briefly
|
||||
setTrailerUrl(null);
|
||||
setTimeout(() => {
|
||||
if (trailerUrl) {
|
||||
setTrailerUrl(trailerUrl);
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
}, 1000);
|
||||
// Capture current URL before clearing it
|
||||
setTrailerUrl(current => {
|
||||
const urlToRestore = current;
|
||||
setTimeout(() => {
|
||||
setTrailerUrl(urlToRestore);
|
||||
}, 500);
|
||||
return null; // Clear first to force remount
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// After 2 retries or for non-retryable errors, show the error
|
||||
logger.error('TrailerModal', 'Video error after retries or non-retryable:', error);
|
||||
setError('Unable to play trailer. Please try again.');
|
||||
setLoading(false);
|
||||
}, [retryCount, trailerUrl]);
|
||||
}, [retryCount]);
|
||||
|
||||
const handleTrailerEnd = useCallback(() => {
|
||||
setIsPlaying(false);
|
||||
|
|
|
|||
Loading…
Reference in a new issue