Skip to content

Commit d49e268

Browse files
authored
fix: show HDMI overlays in fullscreen mode (#974)
1 parent e293edb commit d49e268

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

ui/src/components/WebRTCVideo.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { m } from "@localizations/messages.js";
2626
export default function WebRTCVideo({ hasConnectionIssues }: { hasConnectionIssues: boolean }) {
2727
// Video and stream related refs and states
2828
const videoElm = useRef<HTMLVideoElement>(null);
29+
const fullscreenContainerRef = useRef<HTMLDivElement>(null);
2930
const { mediaStream, peerConnectionState } = useRTCStore();
3031
const [isPlaying, setIsPlaying] = useState(false);
3132
const [isPointerLockActive, setIsPointerLockActive] = useState(false);
@@ -150,7 +151,7 @@ export default function WebRTCVideo({ hasConnectionIssues }: { hasConnectionIssu
150151
}, [checkNavigatorPermissions, setIsKeyboardLockActive]);
151152

152153
const releaseKeyboardLock = useCallback(async () => {
153-
if (videoElm.current === null || document.fullscreenElement !== videoElm.current) return;
154+
if (fullscreenContainerRef.current === null || document.fullscreenElement !== fullscreenContainerRef.current) return;
154155

155156
if (navigator && "keyboard" in navigator) {
156157
try {
@@ -187,7 +188,7 @@ export default function WebRTCVideo({ hasConnectionIssues }: { hasConnectionIssu
187188
}, [isPointerLockPossible]);
188189

189190
const requestFullscreen = useCallback(async () => {
190-
if (!isFullscreenEnabled || !videoElm.current) return;
191+
if (!isFullscreenEnabled || !fullscreenContainerRef.current) return;
191192

192193
// per https://wicg.github.io/keyboard-lock/#system-key-press-handler
193194
// If keyboard lock is activated after fullscreen is already in effect, then the user my
@@ -196,7 +197,7 @@ export default function WebRTCVideo({ hasConnectionIssues }: { hasConnectionIssu
196197
await requestKeyboardLock();
197198
await requestPointerLock();
198199

199-
await videoElm.current.requestFullscreen({
200+
await fullscreenContainerRef.current.requestFullscreen({
200201
navigationUI: "show",
201202
});
202203
}, [isFullscreenEnabled, requestKeyboardLock, requestPointerLock]);
@@ -512,7 +513,10 @@ export default function WebRTCVideo({ hasConnectionIssues }: { hasConnectionIssu
512513
{/* In relative mouse mode and under https, we enable the pointer lock, and to do so we need a bar to show the user to click on the video to enable mouse control */}
513514
<PointerLockBar show={showPointerLockBar} />
514515
<div className="relative mx-4 my-2 flex items-center justify-center overflow-hidden">
515-
<div className="relative flex h-full w-full items-center justify-center">
516+
<div
517+
ref={fullscreenContainerRef}
518+
className="relative flex h-full w-full items-center justify-center"
519+
>
516520
<video
517521
ref={videoElm}
518522
autoPlay

0 commit comments

Comments
 (0)