mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-20 07:26:19 +00:00
🆙 Fix the black screen in some cases
This commit is contained in:
@@ -17,42 +17,48 @@ export const FurnitureYoutubeDisplayView: FC<{}> = FurnitureYoutubeDisplayViewPr
|
|||||||
|
|
||||||
const onStateChange = (event: { target: YouTubePlayer; data: number }) =>
|
const onStateChange = (event: { target: YouTubePlayer; data: number }) =>
|
||||||
{
|
{
|
||||||
setPlayer(event.target);
|
try
|
||||||
|
|
||||||
if(objectId === -1) return;
|
|
||||||
|
|
||||||
switch(event.target.getPlayerState())
|
|
||||||
{
|
{
|
||||||
case -1:
|
setPlayer(event.target);
|
||||||
case 1:
|
|
||||||
if(currentVideoState === 2)
|
|
||||||
{
|
|
||||||
//event.target.pauseVideo();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(currentVideoState !== 1) play();
|
if(objectId === -1) return;
|
||||||
return;
|
|
||||||
case 2:
|
switch(event.target.getPlayerState())
|
||||||
if(currentVideoState !== 2) pause();
|
{
|
||||||
|
case -1:
|
||||||
|
case 1:
|
||||||
|
if(currentVideoState !== 1) play();
|
||||||
|
return;
|
||||||
|
case 2:
|
||||||
|
if(currentVideoState !== 2) pause();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
catch(err) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() =>
|
useEffect(() =>
|
||||||
{
|
{
|
||||||
if((currentVideoState === null) || !player) return;
|
if((currentVideoState === null) || !player) return;
|
||||||
|
|
||||||
if((currentVideoState === YoutubeVideoPlaybackStateEnum.PLAYING) && (player.getPlayerState() !== YoutubeVideoPlaybackStateEnum.PLAYING))
|
try
|
||||||
{
|
{
|
||||||
player.playVideo();
|
if((currentVideoState === YoutubeVideoPlaybackStateEnum.PLAYING) && (player.getPlayerState() !== YoutubeVideoPlaybackStateEnum.PLAYING))
|
||||||
|
{
|
||||||
|
player.playVideo();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if((currentVideoState === YoutubeVideoPlaybackStateEnum.PAUSED) && (player.getPlayerState() !== YoutubeVideoPlaybackStateEnum.PAUSED))
|
||||||
|
{
|
||||||
|
player.pauseVideo();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
catch(err)
|
||||||
if((currentVideoState === YoutubeVideoPlaybackStateEnum.PAUSED) && (player.getPlayerState() !== YoutubeVideoPlaybackStateEnum.PAUSED))
|
|
||||||
{
|
{
|
||||||
player.pauseVideo();
|
setPlayer(null);
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}, [ currentVideoState, player ]);
|
}, [ currentVideoState, player ]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user