Merge pull request #1306 from vector-im/SimonBrandner/fix/auto-mute
This commit is contained in:
@@ -37,6 +37,12 @@ import { findDeviceByName } from "../media-utils";
|
||||
import { OpenIDLoader } from "../livekit/OpenIDLoader";
|
||||
import { ActiveCall } from "./InCallView";
|
||||
|
||||
/**
|
||||
* If there already is this many participants in the call, we automatically mute
|
||||
* the user
|
||||
*/
|
||||
const MUTE_PARTICIPANT_COUNT = 8;
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
groupCall?: GroupCall;
|
||||
@@ -229,6 +235,8 @@ export function GroupCallView({
|
||||
groupCall.enter();
|
||||
}, [groupCall]);
|
||||
|
||||
console.log("LOG participant size", participants.size);
|
||||
|
||||
if (error) {
|
||||
return <ErrorView error={error} />;
|
||||
} else if (state === GroupCallState.Entered && userChoices) {
|
||||
@@ -293,7 +301,7 @@ export function GroupCallView({
|
||||
setUserChoices(choices);
|
||||
enter();
|
||||
}}
|
||||
muteAudio={participants.size > 8}
|
||||
initWithMutedAudio={participants.size > MUTE_PARTICIPANT_COUNT}
|
||||
isEmbedded={isEmbedded}
|
||||
hideHeader={hideHeader}
|
||||
/>
|
||||
|
||||
@@ -33,7 +33,7 @@ interface Props {
|
||||
onEnter: (userChoices: UserChoices) => void;
|
||||
isEmbedded: boolean;
|
||||
hideHeader: boolean;
|
||||
muteAudio: boolean;
|
||||
initWithMutedAudio: boolean;
|
||||
}
|
||||
|
||||
export function LobbyView(props: Props) {
|
||||
@@ -67,7 +67,7 @@ export function LobbyView(props: Props) {
|
||||
<div className={styles.joinRoomContent}>
|
||||
<VideoPreview
|
||||
matrixInfo={props.matrixInfo}
|
||||
muteAudio={props.muteAudio}
|
||||
initWithMutedAudio={props.initWithMutedAudio}
|
||||
onUserChoicesChanged={setUserChoices}
|
||||
/>
|
||||
<Trans>
|
||||
|
||||
@@ -40,13 +40,13 @@ export type MatrixInfo = {
|
||||
|
||||
interface Props {
|
||||
matrixInfo: MatrixInfo;
|
||||
muteAudio: boolean;
|
||||
initWithMutedAudio: boolean;
|
||||
onUserChoicesChanged: (choices: UserChoices) => void;
|
||||
}
|
||||
|
||||
export function VideoPreview({
|
||||
matrixInfo,
|
||||
muteAudio,
|
||||
initWithMutedAudio,
|
||||
onUserChoicesChanged,
|
||||
}: Props) {
|
||||
const { client } = useClient();
|
||||
@@ -69,13 +69,9 @@ export function VideoPreview({
|
||||
|
||||
// Create local media tracks.
|
||||
const [videoEnabled, setVideoEnabled] = useState<boolean>(true);
|
||||
const [audioEnabled, setAudioEnabled] = useState<boolean>(!muteAudio);
|
||||
|
||||
useEffect(() => {
|
||||
if (muteAudio) {
|
||||
setAudioEnabled(false);
|
||||
}
|
||||
}, [muteAudio]);
|
||||
const [audioEnabled, setAudioEnabled] = useState<boolean>(
|
||||
!initWithMutedAudio
|
||||
);
|
||||
|
||||
// The settings are updated as soon as the device changes. We wrap the settings value in a ref to store their initial value.
|
||||
// Not changing the device options prohibits the usePreviewTracks hook to recreate the tracks.
|
||||
|
||||
@@ -171,7 +171,7 @@ export function useGroupCall(
|
||||
isScreensharing: false,
|
||||
screenshareFeeds: [],
|
||||
requestingScreenshare: false,
|
||||
participants: new Map(),
|
||||
participants: getParticipants(groupCall),
|
||||
hasLocalParticipant: false,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user