This commit is contained in:
2024-02-06 13:20:47 +05:00
parent 4e5e013c97
commit 42f07f410e
7 changed files with 1041 additions and 829 deletions
+11 -1
View File
@@ -8,6 +8,7 @@ import {
PixelStreaming,
} from "@epicgames-ps/lib-pixelstreamingfrontend-ue5.3";
import { Trans } from "react-i18next";
import LoaderIcon from "./icons/LoaderIcon";
export interface PixelStreamingWrapperProps {
initialSettings?: Partial<AllSettings>;
@@ -25,6 +26,8 @@ export const PixelStreamingWrapper = ({
// A boolean state variable that determines if the Click to play overlay is shown:
const [clickToPlayVisible, setClickToPlayVisible] = useState<boolean>(false);
const [videoInitialized, setVideoInitialized] = useState<boolean>(false);
const videoInitializedRef = useRef<boolean>();
videoInitializedRef.current = videoInitialized;
// Run on component mount:
useEffect(() => {
@@ -50,6 +53,12 @@ export const PixelStreamingWrapper = ({
document.getElementById("hiddenInput")?.remove();
document.getElementById("editTextButton")?.remove();
setTimeout(() => {
if (!videoInitializedRef.current) {
window.location.reload();
}
}, 10000);
// Clean up on component unmount:
return () => {
try {
@@ -65,7 +74,8 @@ export const PixelStreamingWrapper = ({
<div className="relative w-screen h-screen">
<div className="w-full h-[100svh]" ref={videoParent} />
{!videoInitialized && (
<div className="absolute top-0 left-0 w-full h-full flex justify-center items-center">
<div className="absolute top-0 left-0 w-full h-full flex justify-center items-center gap-4">
<LoaderIcon className="animate-spin w-8 h-8" />
<Trans i18nKey="streamBuffering">Буферизация потока</Trans>
</div>
)}