mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-03-11 17:45:38 +00:00
critical videoplayer bug fix
This commit is contained in:
parent
7213766bb0
commit
9c12f9fc08
3 changed files with 55 additions and 10 deletions
|
|
@ -1 +1 @@
|
|||
Subproject commit 46fce12a69ce684962a76893520e89fec18e0989
|
||||
Subproject commit 63d560d55f1a84a16318525ad4eb1db5162e059c
|
||||
|
|
@ -518,10 +518,18 @@ const AndroidVideoPlayer: React.FC = () => {
|
|||
};
|
||||
|
||||
const onLoad = (data: any) => {
|
||||
if (DEBUG_MODE) {
|
||||
logger.log('[AndroidVideoPlayer] Video loaded:', data);
|
||||
}
|
||||
if (isMounted.current) {
|
||||
try {
|
||||
if (DEBUG_MODE) {
|
||||
logger.log('[AndroidVideoPlayer] Video loaded:', data);
|
||||
}
|
||||
if (!isMounted.current) {
|
||||
logger.warn('[AndroidVideoPlayer] Component unmounted, skipping onLoad');
|
||||
return;
|
||||
}
|
||||
if (!data) {
|
||||
logger.error('[AndroidVideoPlayer] onLoad called with null/undefined data');
|
||||
return;
|
||||
}
|
||||
const videoDuration = data.duration;
|
||||
if (data.duration > 0) {
|
||||
setDuration(videoDuration);
|
||||
|
|
@ -541,6 +549,10 @@ const AndroidVideoPlayer: React.FC = () => {
|
|||
// Set aspect ratio from video dimensions
|
||||
if (data.naturalSize && data.naturalSize.width && data.naturalSize.height) {
|
||||
setVideoAspectRatio(data.naturalSize.width / data.naturalSize.height);
|
||||
} else {
|
||||
// Fallback to 16:9 aspect ratio if naturalSize is not available
|
||||
setVideoAspectRatio(16 / 9);
|
||||
logger.warn('[AndroidVideoPlayer] naturalSize not available, using default 16:9 aspect ratio');
|
||||
}
|
||||
|
||||
// Handle audio tracks
|
||||
|
|
@ -585,6 +597,15 @@ const AndroidVideoPlayer: React.FC = () => {
|
|||
}
|
||||
completeOpeningAnimation();
|
||||
controlsTimeout.current = setTimeout(hideControls, 5000);
|
||||
} catch (error) {
|
||||
logger.error('[AndroidVideoPlayer] Error in onLoad:', error);
|
||||
// Set fallback values to prevent crashes
|
||||
if (isMounted.current) {
|
||||
setVideoAspectRatio(16 / 9);
|
||||
setIsVideoLoaded(true);
|
||||
setIsPlayerReady(true);
|
||||
completeOpeningAnimation();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -578,10 +578,18 @@ const VideoPlayer: React.FC = () => {
|
|||
};
|
||||
|
||||
const onLoad = (data: any) => {
|
||||
if (DEBUG_MODE) {
|
||||
logger.log('[VideoPlayer] Video loaded:', data);
|
||||
}
|
||||
if (isMounted.current) {
|
||||
try {
|
||||
if (DEBUG_MODE) {
|
||||
logger.log('[VideoPlayer] Video loaded:', data);
|
||||
}
|
||||
if (!isMounted.current) {
|
||||
logger.warn('[VideoPlayer] Component unmounted, skipping onLoad');
|
||||
return;
|
||||
}
|
||||
if (!data) {
|
||||
logger.error('[VideoPlayer] onLoad called with null/undefined data');
|
||||
return;
|
||||
}
|
||||
const videoDuration = data.duration / 1000;
|
||||
if (data.duration > 0) {
|
||||
setDuration(videoDuration);
|
||||
|
|
@ -597,7 +605,14 @@ const VideoPlayer: React.FC = () => {
|
|||
}
|
||||
}
|
||||
}
|
||||
setVideoAspectRatio(data.videoSize.width / data.videoSize.height);
|
||||
// Set aspect ratio with null check for videoSize
|
||||
if (data.videoSize && data.videoSize.width && data.videoSize.height) {
|
||||
setVideoAspectRatio(data.videoSize.width / data.videoSize.height);
|
||||
} else {
|
||||
// Fallback to 16:9 aspect ratio if videoSize is not available
|
||||
setVideoAspectRatio(16 / 9);
|
||||
logger.warn('[VideoPlayer] videoSize not available, using default 16:9 aspect ratio');
|
||||
}
|
||||
|
||||
if (data.audioTracks && data.audioTracks.length > 0) {
|
||||
setVlcAudioTracks(data.audioTracks);
|
||||
|
|
@ -628,6 +643,15 @@ const VideoPlayer: React.FC = () => {
|
|||
}
|
||||
completeOpeningAnimation();
|
||||
controlsTimeout.current = setTimeout(hideControls, 5000);
|
||||
} catch (error) {
|
||||
logger.error('[VideoPlayer] Error in onLoad:', error);
|
||||
// Set fallback values to prevent crashes
|
||||
if (isMounted.current) {
|
||||
setVideoAspectRatio(16 / 9);
|
||||
setIsVideoLoaded(true);
|
||||
setIsPlayerReady(true);
|
||||
completeOpeningAnimation();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue