feat(call): add sound effects and incoming call notification UI
- Implemented sound management for call events including mute, unmute, deafen, undeafen, call joined, call depart, and dialing sounds. - Created a new CallSounds class to handle sound playback and state management. - Added IncomingCallNotification component to display incoming call alerts with caller information and action buttons. - Styled the incoming call notification using vanilla-extract CSS for animations and layout. - Integrated sound playback for incoming calls with a 15-second threshold for dialing sound.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable no-console */
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { MatrixEvent, Room, RoomStateEvent } from 'matrix-js-sdk';
|
||||
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||
@@ -25,20 +26,20 @@ function getActiveCallMembers(room: Room): CallMember[] {
|
||||
try {
|
||||
const stateEvents = room.currentState.getStateEvents(CALL_MEMBER_EVENT_TYPE);
|
||||
|
||||
for (const event of stateEvents) {
|
||||
stateEvents.forEach((event) => {
|
||||
const content = event.getContent();
|
||||
const userId = event.getStateKey();
|
||||
|
||||
if (!userId || !content['m.calls']) continue;
|
||||
if (!userId || !content['m.calls']) return;
|
||||
|
||||
const calls = content['m.calls'];
|
||||
if (!Array.isArray(calls)) continue;
|
||||
if (!Array.isArray(calls)) return;
|
||||
|
||||
for (const call of calls) {
|
||||
calls.forEach((call) => {
|
||||
const devices = call['m.devices'];
|
||||
if (!Array.isArray(devices)) continue;
|
||||
if (!Array.isArray(devices)) return;
|
||||
|
||||
for (const device of devices) {
|
||||
devices.forEach((device) => {
|
||||
const expiresTs = device.expires_ts || 0;
|
||||
|
||||
// Check if the call membership is still valid (not expired)
|
||||
@@ -50,9 +51,9 @@ function getActiveCallMembers(room: Room): CallMember[] {
|
||||
expiresTs,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('Error reading call member events:', e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user