mirror of
https://github.com/vector-im/element-call.git
synced 2026-08-29 21:15:19 +00:00
Updates sounds in renderer
This commit is contained in:
@@ -14,11 +14,15 @@ import {
|
|||||||
useSetting,
|
useSetting,
|
||||||
} from "../settings/settings";
|
} from "../settings/settings";
|
||||||
import { CallViewModel } from "../state/CallViewModel";
|
import { CallViewModel } from "../state/CallViewModel";
|
||||||
// TODO: These need replacing with something more pleasant.
|
|
||||||
import enterCallSoundMp3 from "../sound/start_talk_local.mp3";
|
import enterCallSoundMp3 from "../sound/join_call.mp3";
|
||||||
import enterCallSoundOgg from "../sound/start_talk_local.ogg";
|
import enterCallSoundOgg from "../sound/join_call.ogg";
|
||||||
import leftCallSoundMp3 from "../sound/start_talk_remote.mp3";
|
import leftCallSoundMp3 from "../sound/left_call.mp3";
|
||||||
import leftCallSoundOgg from "../sound/start_talk_remote.ogg";
|
import leftCallSoundOgg from "../sound/left_call.ogg";
|
||||||
|
|
||||||
|
// Do not play any sounds if the participant count has exceeded this
|
||||||
|
// number.
|
||||||
|
export const MAX_PARTICIPANT_COUNT_FOR_SOUND = 8;
|
||||||
|
|
||||||
export function CallEventAudioRenderer({
|
export function CallEventAudioRenderer({
|
||||||
vm,
|
vm,
|
||||||
@@ -33,6 +37,10 @@ export function CallEventAudioRenderer({
|
|||||||
const callLeft = useRef<HTMLAudioElement>(null);
|
const callLeft = useRef<HTMLAudioElement>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (memberIds.length > MAX_PARTICIPANT_COUNT_FOR_SOUND) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const memberLeft = !!previousMembers.filter((m) => !memberIds.includes(m))
|
const memberLeft = !!previousMembers.filter((m) => !memberIds.includes(m))
|
||||||
.length;
|
.length;
|
||||||
const memberJoined = !!memberIds.filter((m) => !previousMembers.includes(m))
|
const memberJoined = !!memberIds.filter((m) => !previousMembers.includes(m))
|
||||||
@@ -56,8 +64,10 @@ export function CallEventAudioRenderer({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
// Will play as soon as it's mounted, which is what we want as this will
|
||||||
|
// play when the call is entered.
|
||||||
<>
|
<>
|
||||||
<audio ref={callEntered} preload="auto" hidden>
|
<audio autoPlay ref={callEntered} preload="auto" hidden>
|
||||||
<source src={enterCallSoundOgg} type="audio/ogg; codecs=vorbis" />
|
<source src={enterCallSoundOgg} type="audio/ogg; codecs=vorbis" />
|
||||||
<source src={enterCallSoundMp3} type="audio/mpeg" />
|
<source src={enterCallSoundMp3} type="audio/mpeg" />
|
||||||
</audio>
|
</audio>
|
||||||
|
|||||||
Reference in New Issue
Block a user