mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-20 15:36:18 +00:00
🆙 Fix the black screen in some cases
This commit is contained in:
@@ -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 { 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 }) =>
|
const onStateChange = (event: { target: YouTubePlayer; data: number }) =>
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
setPlayer(event.target);
|
setPlayer(event.target);
|
||||||
|
|
||||||
@@ -25,22 +27,21 @@ export const FurnitureYoutubeDisplayView: FC<{}> = FurnitureYoutubeDisplayViewPr
|
|||||||
{
|
{
|
||||||
case -1:
|
case -1:
|
||||||
case 1:
|
case 1:
|
||||||
if(currentVideoState === 2)
|
|
||||||
{
|
|
||||||
//event.target.pauseVideo();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(currentVideoState !== 1) play();
|
if(currentVideoState !== 1) play();
|
||||||
return;
|
return;
|
||||||
case 2:
|
case 2:
|
||||||
if(currentVideoState !== 2) pause();
|
if(currentVideoState !== 2) pause();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch(err) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() =>
|
useEffect(() =>
|
||||||
{
|
{
|
||||||
if((currentVideoState === null) || !player) return;
|
if((currentVideoState === null) || !player) return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
if((currentVideoState === YoutubeVideoPlaybackStateEnum.PLAYING) && (player.getPlayerState() !== YoutubeVideoPlaybackStateEnum.PLAYING))
|
if((currentVideoState === YoutubeVideoPlaybackStateEnum.PLAYING) && (player.getPlayerState() !== YoutubeVideoPlaybackStateEnum.PLAYING))
|
||||||
{
|
{
|
||||||
player.playVideo();
|
player.playVideo();
|
||||||
@@ -54,6 +55,11 @@ export const FurnitureYoutubeDisplayView: FC<{}> = FurnitureYoutubeDisplayViewPr
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch(err)
|
||||||
|
{
|
||||||
|
setPlayer(null);
|
||||||
|
}
|
||||||
}, [ currentVideoState, player ]);
|
}, [ currentVideoState, player ]);
|
||||||
|
|
||||||
if(objectId === -1) return null;
|
if(objectId === -1) return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user