import React, { useState } from 'react'; import cn from 'classnames'; import { Icon } from 'UI'; import { Button } from 'antd'; import type { LocalStream } from 'Player'; import stl from './ChatControls.module.css'; interface Props { stream: LocalStream | null, endCall: () => void, videoEnabled: boolean, isPrestart?: boolean, setVideoEnabled: (isEnabled: boolean) => void } function ChatControls({ stream, endCall, videoEnabled, setVideoEnabled, isPrestart, } : Props) { const [audioEnabled, setAudioEnabled] = useState(true); const toggleAudio = () => { if (!stream) { return; } setAudioEnabled(stream.toggleAudio()); }; const toggleVideo = () => { if (!stream) { return; } stream.toggleVideo() .then((v) => setVideoEnabled(v)); }; /** muting user if he is auto connected to the call */ React.useEffect(() => { if (isPrestart) { audioEnabled && toggleAudio(); } }, []); return (
); } export default ChatControls;