2022-05-04 17:09:48 +01:00
|
|
|
/*
|
|
|
|
Copyright 2022 Matrix.org Foundation C.I.C.
|
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2022-05-31 10:43:05 -04:00
|
|
|
import React, { forwardRef } from "react";
|
2022-04-07 14:22:36 -07:00
|
|
|
import { animated } from "@react-spring/web";
|
|
|
|
import classNames from "classnames";
|
|
|
|
import styles from "./VideoTile.module.css";
|
|
|
|
import { ReactComponent as MicMutedIcon } from "../icons/MicMuted.svg";
|
|
|
|
import { ReactComponent as VideoMutedIcon } from "../icons/VideoMuted.svg";
|
2022-08-01 18:56:59 +02:00
|
|
|
import { AudioButton } from "../button/Button";
|
2022-04-07 14:22:36 -07:00
|
|
|
|
2022-05-31 10:43:05 -04:00
|
|
|
export const VideoTile = forwardRef(
|
|
|
|
(
|
|
|
|
{
|
|
|
|
className,
|
|
|
|
isLocal,
|
|
|
|
speaking,
|
|
|
|
audioMuted,
|
|
|
|
noVideo,
|
|
|
|
videoMuted,
|
|
|
|
screenshare,
|
|
|
|
avatar,
|
|
|
|
name,
|
|
|
|
showName,
|
|
|
|
mediaRef,
|
2022-07-15 11:18:56 +02:00
|
|
|
onOptionsPress,
|
|
|
|
showOptions,
|
2022-05-31 10:43:05 -04:00
|
|
|
...rest
|
|
|
|
},
|
|
|
|
ref
|
|
|
|
) => {
|
|
|
|
return (
|
|
|
|
<animated.div
|
|
|
|
className={classNames(styles.videoTile, className, {
|
|
|
|
[styles.isLocal]: isLocal,
|
|
|
|
[styles.speaking]: speaking,
|
|
|
|
[styles.muted]: audioMuted,
|
|
|
|
[styles.screenshare]: screenshare,
|
|
|
|
})}
|
|
|
|
ref={ref}
|
|
|
|
{...rest}
|
|
|
|
>
|
|
|
|
{(videoMuted || noVideo) && (
|
|
|
|
<>
|
|
|
|
<div className={styles.videoMutedOverlay} />
|
|
|
|
{avatar}
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
{screenshare ? (
|
|
|
|
<div className={styles.presenterLabel}>
|
|
|
|
<span>{`${name} is presenting`}</span>
|
2022-04-07 14:22:36 -07:00
|
|
|
</div>
|
2022-05-31 10:43:05 -04:00
|
|
|
) : (
|
|
|
|
(showName || audioMuted || (videoMuted && !noVideo)) && (
|
2022-08-01 18:56:59 +02:00
|
|
|
<div
|
|
|
|
className={classNames(
|
|
|
|
styles.infoBubble,
|
|
|
|
styles.memberName,
|
|
|
|
styles.infoBubbleIcon
|
|
|
|
)}
|
|
|
|
>
|
2022-05-31 10:43:05 -04:00
|
|
|
{audioMuted && !(videoMuted && !noVideo) && <MicMutedIcon />}
|
|
|
|
{videoMuted && !noVideo && <VideoMutedIcon />}
|
|
|
|
{showName && <span title={name}>{name}</span>}
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
)}
|
2022-07-15 11:18:56 +02:00
|
|
|
{showOptions && (
|
2022-08-01 18:56:59 +02:00
|
|
|
<div
|
|
|
|
className={classNames(
|
|
|
|
styles.infoBubble,
|
|
|
|
styles.button,
|
|
|
|
styles.audioButton
|
|
|
|
)}
|
|
|
|
>
|
|
|
|
<AudioButton onPress={onOptionsPress} />
|
2022-07-15 11:18:56 +02:00
|
|
|
</div>
|
|
|
|
)}
|
2022-05-31 10:43:05 -04:00
|
|
|
<video ref={mediaRef} playsInline disablePictureInPicture />
|
|
|
|
</animated.div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|