🆙 Fix the black screen in some cases

This commit is contained in:
duckietm
2026-03-31 14:55:29 +02:00
parent 6609c0325f
commit 57f6960735
@@ -16,6 +16,8 @@ export const FurnitureYoutubeDisplayView: FC<{}> = FurnitureYoutubeDisplayViewPr
const { objectId = -1, videoId = null, videoStart = 0, videoEnd = 0, currentVideoState = null, selectedVideo = null, playlists = [], onClose = null, previous = null, next = null, pause = null, play = null, selectVideo = null } = useFurnitureYoutubeWidget();
const onStateChange = (event: { target: YouTubePlayer; data: number }) =>
{
try
{
setPlayer(event.target);
@@ -25,22 +27,21 @@ export const FurnitureYoutubeDisplayView: FC<{}> = FurnitureYoutubeDisplayViewPr
{
case -1:
case 1:
if(currentVideoState === 2)
{
//event.target.pauseVideo();
}
if(currentVideoState !== 1) play();
return;
case 2:
if(currentVideoState !== 2) pause();
}
}
catch(err) {}
};
useEffect(() =>
{
if((currentVideoState === null) || !player) return;
try
{
if((currentVideoState === YoutubeVideoPlaybackStateEnum.PLAYING) && (player.getPlayerState() !== YoutubeVideoPlaybackStateEnum.PLAYING))
{
player.playVideo();
@@ -54,6 +55,11 @@ export const FurnitureYoutubeDisplayView: FC<{}> = FurnitureYoutubeDisplayViewPr
return;
}
}
catch(err)
{
setPlayer(null);
}
}, [ currentVideoState, player ]);
if(objectId === -1) return null;