Merge pull request #502 from vector-im/SimonBrandner/feat/fullscreen
This commit is contained in:
commit
5474693711
9 changed files with 220 additions and 57 deletions
|
@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
import React, { forwardRef } from "react";
|
import React, { forwardRef, useCallback } from "react";
|
||||||
import { PressEvent } from "@react-types/shared";
|
import { PressEvent } from "@react-types/shared";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import { useButton } from "@react-aria/button";
|
import { useButton } from "@react-aria/button";
|
||||||
|
@ -29,6 +29,8 @@ import { ReactComponent as ScreenshareIcon } from "../icons/Screenshare.svg";
|
||||||
import { ReactComponent as SettingsIcon } from "../icons/Settings.svg";
|
import { ReactComponent as SettingsIcon } from "../icons/Settings.svg";
|
||||||
import { ReactComponent as AddUserIcon } from "../icons/AddUser.svg";
|
import { ReactComponent as AddUserIcon } from "../icons/AddUser.svg";
|
||||||
import { ReactComponent as ArrowDownIcon } from "../icons/ArrowDown.svg";
|
import { ReactComponent as ArrowDownIcon } from "../icons/ArrowDown.svg";
|
||||||
|
import { ReactComponent as Fullscreen } from "../icons/Fullscreen.svg";
|
||||||
|
import { ReactComponent as FullscreenExit } from "../icons/FullscreenExit.svg";
|
||||||
import { TooltipTrigger } from "../Tooltip";
|
import { TooltipTrigger } from "../Tooltip";
|
||||||
import { VolumeIcon } from "./VolumeIcon";
|
import { VolumeIcon } from "./VolumeIcon";
|
||||||
|
|
||||||
|
@ -262,3 +264,24 @@ export function AudioButton({ volume, ...rest }: AudioButtonProps) {
|
||||||
</TooltipTrigger>
|
</TooltipTrigger>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface FullscreenButtonProps extends Omit<Props, "variant"> {
|
||||||
|
fullscreen?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function FullscreenButton({
|
||||||
|
fullscreen,
|
||||||
|
...rest
|
||||||
|
}: FullscreenButtonProps) {
|
||||||
|
const getTooltip = useCallback(() => {
|
||||||
|
return fullscreen ? "Exit full screen" : "Full screen";
|
||||||
|
}, [fullscreen]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<TooltipTrigger tooltip={getTooltip}>
|
||||||
|
<Button variant="icon" {...rest}>
|
||||||
|
{fullscreen ? <FullscreenExit /> : <Fullscreen />}
|
||||||
|
</Button>
|
||||||
|
</TooltipTrigger>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
3
src/icons/Fullscreen.svg
Normal file
3
src/icons/Fullscreen.svg
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M21 8.59V4C21 3.45 20.55 3 20 3H15.41C14.52 3 14.07 4.08 14.7 4.71L16.29 6.3L6.29 16.3L4.7 14.71C4.08 14.08 3 14.52 3 15.41V20C3 20.55 3.45 21 4 21H8.59C9.48 21 9.93 19.92 9.3 19.29L7.71 17.7L17.71 7.7L19.3 9.29C19.92 9.92 21 9.48 21 8.59Z" fill="white"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 368 B |
3
src/icons/FullscreenExit.svg
Normal file
3
src/icons/FullscreenExit.svg
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M21.29 4.12L16.7 8.71L18.29 10.3C18.92 10.93 18.47 12.01 17.58 12.01H13C12.45 12.01 12 11.56 12 11.01V6.41C12 5.52 13.08 5.07 13.71 5.7L15.3 7.29L19.89 2.7C20.28 2.31 20.91 2.31 21.3 2.7C21.68 3.1 21.68 3.73 21.29 4.12ZM4.11997 21.29L8.70997 16.7L10.3 18.29C10.93 18.92 12.01 18.47 12.01 17.58V13C12.01 12.45 11.56 12 11.01 12H6.40997C5.51997 12 5.06997 13.08 5.69997 13.71L7.28997 15.3L2.69997 19.89C2.30997 20.28 2.30997 20.91 2.69997 21.3C3.09997 21.68 3.72997 21.68 4.11997 21.29Z" fill="white"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 613 B |
|
@ -54,6 +54,12 @@ limitations under the License.
|
||||||
margin-right: 0px;
|
margin-right: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.footerFullscreen {
|
||||||
|
position: absolute;
|
||||||
|
width: 100%;
|
||||||
|
bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.avatar {
|
.avatar {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
|
|
|
@ -14,10 +14,11 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React, { useCallback, useMemo } from "react";
|
import React, { useCallback, useMemo, useRef } from "react";
|
||||||
import { usePreventScroll } from "@react-aria/overlays";
|
import { usePreventScroll } from "@react-aria/overlays";
|
||||||
import { GroupCall, MatrixClient } from "matrix-js-sdk";
|
import { GroupCall, MatrixClient } from "matrix-js-sdk";
|
||||||
import { CallFeed } from "matrix-js-sdk/src/webrtc/callFeed";
|
import { CallFeed } from "matrix-js-sdk/src/webrtc/callFeed";
|
||||||
|
import classNames from "classnames";
|
||||||
|
|
||||||
import styles from "./InCallView.module.css";
|
import styles from "./InCallView.module.css";
|
||||||
import {
|
import {
|
||||||
|
@ -46,6 +47,7 @@ import { useMediaHandler } from "../settings/useMediaHandler";
|
||||||
import { useShowInspector } from "../settings/useSetting";
|
import { useShowInspector } from "../settings/useSetting";
|
||||||
import { useModalTriggerState } from "../Modal";
|
import { useModalTriggerState } from "../Modal";
|
||||||
import { useAudioContext } from "../video-grid/useMediaStream";
|
import { useAudioContext } from "../video-grid/useMediaStream";
|
||||||
|
import { useFullscreen } from "../video-grid/useFullscreen";
|
||||||
|
|
||||||
const canScreenshare = "getDisplayMedia" in (navigator.mediaDevices ?? {});
|
const canScreenshare = "getDisplayMedia" in (navigator.mediaDevices ?? {});
|
||||||
// There is currently a bug in Safari our our code with cloning and sending MediaStreams
|
// There is currently a bug in Safari our our code with cloning and sending MediaStreams
|
||||||
|
@ -72,7 +74,8 @@ interface Props {
|
||||||
roomId: string;
|
roomId: string;
|
||||||
unencryptedEventsFromUsers: Set<string>;
|
unencryptedEventsFromUsers: Set<string>;
|
||||||
}
|
}
|
||||||
interface Participant {
|
|
||||||
|
export interface Participant {
|
||||||
id: string;
|
id: string;
|
||||||
callFeed: CallFeed;
|
callFeed: CallFeed;
|
||||||
focused: boolean;
|
focused: boolean;
|
||||||
|
@ -100,7 +103,9 @@ export function InCallView({
|
||||||
unencryptedEventsFromUsers,
|
unencryptedEventsFromUsers,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
usePreventScroll();
|
usePreventScroll();
|
||||||
|
const elementRef = useRef<HTMLDivElement>();
|
||||||
const [layout, setLayout] = useVideoGridLayout(screenshareFeeds.length > 0);
|
const [layout, setLayout] = useVideoGridLayout(screenshareFeeds.length > 0);
|
||||||
|
const { toggleFullscreen, fullscreenParticipant } = useFullscreen(elementRef);
|
||||||
|
|
||||||
const [audioContext, audioDestination, audioRef] = useAudioContext();
|
const [audioContext, audioDestination, audioRef] = useAudioContext();
|
||||||
const { audioOutput } = useMediaHandler();
|
const { audioOutput } = useMediaHandler();
|
||||||
|
@ -161,14 +166,73 @@ export function InCallView({
|
||||||
);
|
);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const renderContent = useCallback((): JSX.Element => {
|
||||||
|
if (items.length === 0) {
|
||||||
|
return (
|
||||||
|
<div className={styles.centerMessage}>
|
||||||
|
<p>Waiting for other participants...</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (fullscreenParticipant) {
|
||||||
|
return (
|
||||||
|
<VideoTileContainer
|
||||||
|
key={fullscreenParticipant.id}
|
||||||
|
item={fullscreenParticipant}
|
||||||
|
getAvatar={renderAvatar}
|
||||||
|
audioOutputDevice={audioOutput}
|
||||||
|
audioContext={audioContext}
|
||||||
|
audioDestination={audioDestination}
|
||||||
|
disableSpeakingIndicator={true}
|
||||||
|
isFullscreen={fullscreenParticipant}
|
||||||
|
onFullscreen={toggleFullscreen}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<VideoGrid items={items} layout={layout} disableAnimations={isSafari}>
|
||||||
|
{({ item, ...rest }: { item: Participant; [x: string]: unknown }) => (
|
||||||
|
<VideoTileContainer
|
||||||
|
key={item.id}
|
||||||
|
item={item}
|
||||||
|
getAvatar={renderAvatar}
|
||||||
|
showName={items.length > 2 || item.focused}
|
||||||
|
audioOutputDevice={audioOutput}
|
||||||
|
audioContext={audioContext}
|
||||||
|
audioDestination={audioDestination}
|
||||||
|
disableSpeakingIndicator={items.length < 3}
|
||||||
|
isFullscreen={fullscreenParticipant}
|
||||||
|
onFullscreen={toggleFullscreen}
|
||||||
|
{...rest}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</VideoGrid>
|
||||||
|
);
|
||||||
|
}, [
|
||||||
|
fullscreenParticipant,
|
||||||
|
items,
|
||||||
|
audioContext,
|
||||||
|
audioDestination,
|
||||||
|
audioOutput,
|
||||||
|
layout,
|
||||||
|
renderAvatar,
|
||||||
|
toggleFullscreen,
|
||||||
|
]);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
modalState: rageshakeRequestModalState,
|
modalState: rageshakeRequestModalState,
|
||||||
modalProps: rageshakeRequestModalProps,
|
modalProps: rageshakeRequestModalProps,
|
||||||
} = useRageshakeRequestModal(groupCall.room.roomId);
|
} = useRageshakeRequestModal(groupCall.room.roomId);
|
||||||
|
|
||||||
|
const footerClassNames = classNames(styles.footer, {
|
||||||
|
[styles.footerFullscreen]: fullscreenParticipant,
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.inRoom}>
|
<div className={styles.inRoom} ref={elementRef}>
|
||||||
<audio ref={audioRef} />
|
<audio ref={audioRef} />
|
||||||
|
{!fullscreenParticipant && (
|
||||||
<Header>
|
<Header>
|
||||||
<LeftNav>
|
<LeftNav>
|
||||||
<RoomHeaderInfo roomName={roomName} avatarUrl={avatarUrl} />
|
<RoomHeaderInfo roomName={roomName} avatarUrl={avatarUrl} />
|
||||||
|
@ -182,36 +246,18 @@ export function InCallView({
|
||||||
<UserMenuContainer preventNavigation />
|
<UserMenuContainer preventNavigation />
|
||||||
</RightNav>
|
</RightNav>
|
||||||
</Header>
|
</Header>
|
||||||
{items.length === 0 ? (
|
|
||||||
<div className={styles.centerMessage}>
|
|
||||||
<p>Waiting for other participants...</p>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<VideoGrid items={items} layout={layout} disableAnimations={isSafari}>
|
|
||||||
{({ item, ...rest }: { item: Participant; [x: string]: unknown }) => (
|
|
||||||
<VideoTileContainer
|
|
||||||
key={item.id}
|
|
||||||
item={item}
|
|
||||||
getAvatar={renderAvatar}
|
|
||||||
showName={items.length > 2 || item.focused}
|
|
||||||
audioOutputDevice={audioOutput}
|
|
||||||
audioContext={audioContext}
|
|
||||||
audioDestination={audioDestination}
|
|
||||||
disableSpeakingIndicator={items.length < 3}
|
|
||||||
{...rest}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
</VideoGrid>
|
{renderContent()}
|
||||||
)}
|
<div className={footerClassNames}>
|
||||||
<div className={styles.footer}>
|
|
||||||
<MicButton muted={microphoneMuted} onPress={toggleMicrophoneMuted} />
|
<MicButton muted={microphoneMuted} onPress={toggleMicrophoneMuted} />
|
||||||
<VideoButton muted={localVideoMuted} onPress={toggleLocalVideoMuted} />
|
<VideoButton muted={localVideoMuted} onPress={toggleLocalVideoMuted} />
|
||||||
{canScreenshare && !isSafari && (
|
{canScreenshare && !isSafari && !fullscreenParticipant && (
|
||||||
<ScreenshareButton
|
<ScreenshareButton
|
||||||
enabled={isScreensharing}
|
enabled={isScreensharing}
|
||||||
onPress={toggleScreensharing}
|
onPress={toggleScreensharing}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
{!fullscreenParticipant && (
|
||||||
<OverflowMenu
|
<OverflowMenu
|
||||||
inCall
|
inCall
|
||||||
roomId={roomId}
|
roomId={roomId}
|
||||||
|
@ -220,6 +266,7 @@ export function InCallView({
|
||||||
feedbackModalState={feedbackModalState}
|
feedbackModalState={feedbackModalState}
|
||||||
feedbackModalProps={feedbackModalProps}
|
feedbackModalProps={feedbackModalProps}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
<HangupButton onPress={onLeave} />
|
<HangupButton onPress={onLeave} />
|
||||||
</div>
|
</div>
|
||||||
<GroupCallInspector
|
<GroupCallInspector
|
||||||
|
|
|
@ -20,7 +20,7 @@ import classNames from "classnames";
|
||||||
import styles from "./VideoTile.module.css";
|
import styles from "./VideoTile.module.css";
|
||||||
import { ReactComponent as MicMutedIcon } from "../icons/MicMuted.svg";
|
import { ReactComponent as MicMutedIcon } from "../icons/MicMuted.svg";
|
||||||
import { ReactComponent as VideoMutedIcon } from "../icons/VideoMuted.svg";
|
import { ReactComponent as VideoMutedIcon } from "../icons/VideoMuted.svg";
|
||||||
import { AudioButton } from "../button/Button";
|
import { AudioButton, FullscreenButton } from "../button/Button";
|
||||||
|
|
||||||
export const VideoTile = forwardRef(
|
export const VideoTile = forwardRef(
|
||||||
(
|
(
|
||||||
|
@ -39,6 +39,8 @@ export const VideoTile = forwardRef(
|
||||||
onOptionsPress,
|
onOptionsPress,
|
||||||
showOptions,
|
showOptions,
|
||||||
localVolume,
|
localVolume,
|
||||||
|
isFullscreen,
|
||||||
|
onFullscreen,
|
||||||
...rest
|
...rest
|
||||||
},
|
},
|
||||||
ref
|
ref
|
||||||
|
@ -50,17 +52,27 @@ export const VideoTile = forwardRef(
|
||||||
[styles.speaking]: speaking,
|
[styles.speaking]: speaking,
|
||||||
[styles.muted]: audioMuted,
|
[styles.muted]: audioMuted,
|
||||||
[styles.screenshare]: screenshare,
|
[styles.screenshare]: screenshare,
|
||||||
|
[styles.fullscreen]: isFullscreen,
|
||||||
})}
|
})}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
{...rest}
|
{...rest}
|
||||||
>
|
>
|
||||||
{showOptions && (
|
{(!isLocal || screenshare) && (
|
||||||
<div className={classNames(styles.toolbar)}>
|
<div className={classNames(styles.toolbar)}>
|
||||||
|
{!isLocal && (
|
||||||
<AudioButton
|
<AudioButton
|
||||||
className={styles.button}
|
className={styles.button}
|
||||||
volume={localVolume}
|
volume={localVolume}
|
||||||
onPress={onOptionsPress}
|
onPress={onOptionsPress}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
|
{screenshare && (
|
||||||
|
<FullscreenButton
|
||||||
|
className={styles.button}
|
||||||
|
fullscreen={isFullscreen}
|
||||||
|
onPress={onFullscreen}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{(videoMuted || noVideo) && (
|
{(videoMuted || noVideo) && (
|
||||||
|
|
|
@ -40,6 +40,11 @@
|
||||||
box-shadow: inset 0 0 0 4px var(--accent) !important;
|
box-shadow: inset 0 0 0 4px var(--accent) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.videoTile.fullscreen {
|
||||||
|
position: relative;
|
||||||
|
border-radius: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.videoTile.screenshare > video {
|
.videoTile.screenshare > video {
|
||||||
object-fit: contain;
|
object-fit: contain;
|
||||||
}
|
}
|
||||||
|
@ -79,11 +84,11 @@
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.videoTile:not(.isLocal):not(:hover) .toolbar {
|
.toolbar:not(:hover) {
|
||||||
display: none;
|
opacity: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.videoTile:not(.isLocal):hover .presenterLabel {
|
.toolbar:hover + .presenterLabel {
|
||||||
top: calc(42px + 20px); /* toolbar + margin */
|
top: calc(42px + 20px); /* toolbar + margin */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ import { useRoomMemberName } from "./useRoomMemberName";
|
||||||
import { VideoTile } from "./VideoTile";
|
import { VideoTile } from "./VideoTile";
|
||||||
import { VideoTileSettingsModal } from "./VideoTileSettingsModal";
|
import { VideoTileSettingsModal } from "./VideoTileSettingsModal";
|
||||||
import { useModalTriggerState } from "../Modal";
|
import { useModalTriggerState } from "../Modal";
|
||||||
|
import { useCallback } from "react";
|
||||||
|
|
||||||
export function VideoTileContainer({
|
export function VideoTileContainer({
|
||||||
item,
|
item,
|
||||||
|
@ -33,6 +34,8 @@ export function VideoTileContainer({
|
||||||
audioContext,
|
audioContext,
|
||||||
audioDestination,
|
audioDestination,
|
||||||
disableSpeakingIndicator,
|
disableSpeakingIndicator,
|
||||||
|
isFullscreen,
|
||||||
|
onFullscreen,
|
||||||
...rest
|
...rest
|
||||||
}) {
|
}) {
|
||||||
const {
|
const {
|
||||||
|
@ -63,6 +66,10 @@ export function VideoTileContainer({
|
||||||
videoTileSettingsModalState.open();
|
videoTileSettingsModalState.open();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onFullscreenCallback = useCallback(() => {
|
||||||
|
onFullscreen(item);
|
||||||
|
}, [onFullscreen, item]);
|
||||||
|
|
||||||
// Firefox doesn't respect the disablePictureInPicture attribute
|
// Firefox doesn't respect the disablePictureInPicture attribute
|
||||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1611831
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=1611831
|
||||||
|
|
||||||
|
@ -81,8 +88,9 @@ export function VideoTileContainer({
|
||||||
mediaRef={mediaRef}
|
mediaRef={mediaRef}
|
||||||
avatar={getAvatar && getAvatar(member, width, height)}
|
avatar={getAvatar && getAvatar(member, width, height)}
|
||||||
onOptionsPress={onOptionsPress}
|
onOptionsPress={onOptionsPress}
|
||||||
showOptions={!item.callFeed.isLocal()}
|
|
||||||
localVolume={localVolume}
|
localVolume={localVolume}
|
||||||
|
isFullscreen={isFullscreen}
|
||||||
|
onFullscreen={onFullscreenCallback}
|
||||||
{...rest}
|
{...rest}
|
||||||
/>
|
/>
|
||||||
{videoTileSettingsModalState.isOpen && (
|
{videoTileSettingsModalState.isOpen && (
|
||||||
|
|
56
src/video-grid/useFullscreen.tsx
Normal file
56
src/video-grid/useFullscreen.tsx
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
/*
|
||||||
|
Copyright 2022 New Vector Ltd
|
||||||
|
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
|
||||||
|
import { Participant } from "../room/InCallView";
|
||||||
|
import { useEventTarget } from "../useEvents";
|
||||||
|
|
||||||
|
export function useFullscreen(ref: React.RefObject<HTMLElement>): {
|
||||||
|
toggleFullscreen: (participant: Participant) => void;
|
||||||
|
fullscreenParticipant: Participant | null;
|
||||||
|
} {
|
||||||
|
const [fullscreenParticipant, setFullscreenParticipant] =
|
||||||
|
useState<Participant | null>(null);
|
||||||
|
|
||||||
|
const toggleFullscreen = useCallback(
|
||||||
|
(participant: Participant) => {
|
||||||
|
if (fullscreenParticipant) {
|
||||||
|
document.exitFullscreen();
|
||||||
|
setFullscreenParticipant(null);
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
ref.current.requestFullscreen();
|
||||||
|
setFullscreenParticipant(participant);
|
||||||
|
} catch (error) {
|
||||||
|
console.warn("Failed to fullscreen:", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[fullscreenParticipant, setFullscreenParticipant, ref]
|
||||||
|
);
|
||||||
|
|
||||||
|
const onFullscreenChanged = useCallback(() => {
|
||||||
|
if (!document.fullscreenElement) {
|
||||||
|
setFullscreenParticipant(null);
|
||||||
|
}
|
||||||
|
}, [setFullscreenParticipant]);
|
||||||
|
|
||||||
|
useEventTarget(ref.current, "fullscreenchange", onFullscreenChanged);
|
||||||
|
|
||||||
|
return { toggleFullscreen, fullscreenParticipant };
|
||||||
|
}
|
Loading…
Reference in a new issue