The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 24, 02:45 UTC
fix(media): preserve playback during fullscreen transitions (#11113)
maria committed
Sep 10, 2026 at 19:50 UTC
a5ac766596bdf6c7d6852ecda453e2a85a7b08d4
2 files changed
+20
-3
apps/mobile/src/components/MediaVideoPlayer.tsx
+11
-2
@@ -19,6 +19,7 @@ function LoadedMediaVideo(props: {
19
}) {
20
const focused = useIsFocused();
21
const active = useRef(focused && AppState.currentState === "active");
22
+ const fullscreen = useRef(false);
23
const [attempt, setAttempt] = useState(0);
24
// Expo's Android player also reports completed playback as idle.
25
const [loadState, setLoadState] = useState<"pending" | "complete" | "error">("pending");
@@ -38,10 +39,12 @@ function LoadedMediaVideo(props: {
39
40
useEffect(() => {
41
active.current = focused && !props.paused && AppState.currentState === "active";
41
- if (!active.current) player.pause();
42
+ if (!focused || props.paused || (!active.current && !fullscreen.current)) player.pause();
43
+ // Native background handling distinguishes Android's fullscreen activity
44
+ // from leaving the app; React Native reports both as background.
45
const subscription = AppState.addEventListener("change", (state) => {
46
active.current = focused && !props.paused && state === "active";
44
- if (!active.current) player.pause();
47
+ if (state === "inactive" || (state === "background" && !fullscreen.current)) player.pause();
48
});
49
return () => subscription.remove();
50
}, [focused, player, props.paused]);
@@ -70,6 +73,12 @@ function LoadedMediaVideo(props: {
73
nativeControls
74
contentFit="contain"
75
fullscreenOptions={{ enable: true }}
76
+ onFullscreenEnter={() => {
77
+ fullscreen.current = true;
78
+ }}
79
+ onFullscreenExit={() => {
80
+ fullscreen.current = false;
81
+ }}
82
allowsPictureInPicture={false}
83
/>
84
{loadState === "error" || (loadState === "complete" && status === "error") ? (
apps/web/src/components/media/MediaVideoPlayer.tsx
+9
-1
@@ -93,11 +93,19 @@ export function MediaVideoPlayer({
93
const video = videoRef.current;
94
if (!video) return;
95
const pauseWhenHidden = () => {
96
- if (document.hidden) video.pause();
96
+ // Native fullscreen can hide the inline page while this video is still visible.
97
+ const fullscreen =
98
+ document.fullscreenElement?.contains(video) ||
99
+ ("webkitDisplayingFullscreen" in video && video.webkitDisplayingFullscreen === true);
100
+ if (document.hidden && !fullscreen) video.pause();
101
};
102
document.addEventListener("visibilitychange", pauseWhenHidden);
103
+ document.addEventListener("fullscreenchange", pauseWhenHidden);
104
+ video.addEventListener("webkitendfullscreen", pauseWhenHidden);
105
return () => {
106
document.removeEventListener("visibilitychange", pauseWhenHidden);
107
+ document.removeEventListener("fullscreenchange", pauseWhenHidden);
108
+ video.removeEventListener("webkitendfullscreen", pauseWhenHidden);
109
video.pause();
110
};
111
}, [src, failed, loadAttempt]);