Fix active speaker and speaking

This commit is contained in:
Robert Long 2021-09-10 16:05:57 -07:00
parent d813509541
commit 01d2a7136c
3 changed files with 15 additions and 17 deletions

View File

@ -328,7 +328,6 @@ export function useGroupCall(client, roomId) {
useEffect(() => {
function onParticipantsChanged(...args) {
console.log(...args);
updateState({ participants: getParticipants(groupCallRef.current) });
}
@ -348,8 +347,8 @@ export function useGroupCall(client, roomId) {
groupCall.on("participants_changed", onParticipantsChanged);
groupCall.on("speaking", onParticipantsChanged);
groupCall.on("mute_state_changed", onParticipantsChanged);
groupCall.on("participant_call_replaced", onParticipantsChanged);
groupCall.on("participant_call_feeds_changed", onParticipantsChanged);
groupCall.on("call_replaced", onParticipantsChanged);
groupCall.on("call_feeds_changed", onParticipantsChanged);
groupCall.on("local_mute_state_changed", onLocalMuteStateChanged);
updateState({
@ -368,14 +367,8 @@ export function useGroupCall(client, roomId) {
groupCall.removeListener("participants_changed", onParticipantsChanged);
groupCall.removeListener("speaking", onParticipantsChanged);
groupCall.removeListener("mute_state_changed", onParticipantsChanged);
groupCall.removeListener(
"participant_call_replaced",
onParticipantsChanged
);
groupCall.removeListener(
"participant_call_feeds_changed",
onParticipantsChanged
);
groupCall.removeListener("call_replaced", onParticipantsChanged);
groupCall.removeListener("call_feeds_changed", onParticipantsChanged);
groupCall.removeListener(
"local_mute_state_changed",
onLocalMuteStateChanged

View File

@ -167,6 +167,10 @@ export function EnteringRoomView() {
}
export function LoadingErrorView({ error }) {
useEffect(() => {
console.error(error);
}, [error]);
return (
<>
<div className={styles.centerMessage}>
@ -190,7 +194,6 @@ function RoomSetupView({
localVideoMuted,
toggleLocalVideoMuted,
toggleMicrophoneMuted,
groupCall,
}) {
const videoRef = useRef();
const [permissionState, setPermissionState] = useState(
@ -206,7 +209,9 @@ function RoomSetupView({
setPermissionState(PermissionState.Granted);
}
})
.catch(() => {
.catch((error) => {
console.error(error);
if (videoRef.current) {
setPermissionState(PermissionState.Denied);
}

View File

@ -436,7 +436,7 @@ export function VideoGrid({ participants, layout }) {
let presenter;
if (layout === "spotlight") {
presenter = participant.activeSpeaker;
presenter = participant.isActiveSpeaker();
} else {
presenter = layout === lastLayoutRef.current ? tile.presenter : false;
}
@ -459,7 +459,7 @@ export function VideoGrid({ participants, layout }) {
key: participant.member.userId,
participant,
remove: false,
presenter: layout === "spotlight" && participant.activeSpeaker,
presenter: layout === "spotlight" && participant.isActiveSpeaker(),
});
}
@ -740,10 +740,10 @@ function ParticipantTile({ style, participant, remove, presenter, ...rest }) {
<animated.div className={styles.participantTile} style={style} {...rest}>
<div
className={classNames(styles.participantName, {
[styles.speaking]: participant.usermediaStream?.speaking,
[styles.speaking]: participant.usermediaFeed?.isSpeaking(),
})}
>
{participant.usermediaStream?.speaking ? (
{participant.usermediaFeed?.isSpeaking() ? (
<MicIcon />
) : participant.isAudioMuted() ? (
<MuteMicIcon className={styles.muteMicIcon} />