mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-03-11 17:45:38 +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) => {
|
const handleVideoError = useCallback((error: any) => {
|
||||||
logger.error('TrailerModal', 'Video error:', error);
|
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 errorCode = error?.error?.code;
|
||||||
const isRetryableError = errorCode === -1102 || errorCode === -1009 || errorCode === -1005;
|
const isRetryableError = errorCode === -1102 || errorCode === -1009 || errorCode === -1005;
|
||||||
|
|
||||||
if (isRetryableError && retryCount < 2) {
|
if (isRetryableError && retryCount < 2) {
|
||||||
// Silent retry - increment count and try again
|
|
||||||
logger.info('TrailerModal', `Retrying video load (attempt ${retryCount + 1}/2)`);
|
logger.info('TrailerModal', `Retrying video load (attempt ${retryCount + 1}/2)`);
|
||||||
setRetryCount(prev => prev + 1);
|
setRetryCount(prev => prev + 1);
|
||||||
|
|
||||||
// Small delay before retry to avoid rapid-fire attempts
|
// Capture current URL before clearing it
|
||||||
|
setTrailerUrl(current => {
|
||||||
|
const urlToRestore = current;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (videoRef.current) {
|
setTrailerUrl(urlToRestore);
|
||||||
// Force video to reload by changing the source briefly
|
}, 500);
|
||||||
setTrailerUrl(null);
|
return null; // Clear first to force remount
|
||||||
setTimeout(() => {
|
});
|
||||||
if (trailerUrl) {
|
|
||||||
setTrailerUrl(trailerUrl);
|
|
||||||
}
|
|
||||||
}, 100);
|
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// After 2 retries or for non-retryable errors, show the error
|
|
||||||
logger.error('TrailerModal', 'Video error after retries or non-retryable:', error);
|
logger.error('TrailerModal', 'Video error after retries or non-retryable:', error);
|
||||||
setError('Unable to play trailer. Please try again.');
|
setError('Unable to play trailer. Please try again.');
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}, [retryCount, trailerUrl]);
|
}, [retryCount]);
|
||||||
|
|
||||||
const handleTrailerEnd = useCallback(() => {
|
const handleTrailerEnd = useCallback(() => {
|
||||||
setIsPlaying(false);
|
setIsPlaying(false);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue