diff --git a/src/room/CallEventAudioRenderer.tsx b/src/room/CallEventAudioRenderer.tsx index d57e3ba5..afc5132b 100644 --- a/src/room/CallEventAudioRenderer.tsx +++ b/src/room/CallEventAudioRenderer.tsx @@ -13,8 +13,10 @@ import joinCallSoundMp3 from "../sound/join_call.mp3"; import joinCallSoundOgg from "../sound/join_call.ogg"; import leftCallSoundMp3 from "../sound/left_call.mp3"; import leftCallSoundOgg from "../sound/left_call.ogg"; -import handSoundOgg from "../sound/raise_hand.ogg?url"; -import handSoundMp3 from "../sound/raise_hand.mp3?url"; +import handSoundOgg from "../sound/raise_hand.ogg"; +import handSoundMp3 from "../sound/raise_hand.mp3"; +import screenShareStartedOgg from "../sound/screen_share_started.ogg"; +import screenShareStartedMp3 from "../sound/screen_share_started.mp3"; import { useAudioContext } from "../useAudioContext"; import { prefetchSounds } from "../soundUtils"; import { useLatest } from "../useLatest"; @@ -37,6 +39,10 @@ export const callEventAudioSounds = prefetchSounds({ mp3: handSoundMp3, ogg: handSoundOgg, }, + screenshareStarted: { + mp3: screenShareStartedMp3, + ogg: screenShareStartedOgg, + }, }); export function CallEventAudioRenderer({ @@ -79,10 +85,15 @@ export function CallEventAudioRenderer({ void audioEngineRef.current?.playSound("raiseHand"); }); + const screenshareSub = vm.newScreenShare$.subscribe(() => { + void audioEngineRef.current?.playSound("screenshareStarted"); + }); + return (): void => { joinSub.unsubscribe(); leftSub.unsubscribe(); handRaisedSub.unsubscribe(); + screenshareSub.unsubscribe(); }; }, [audioEngineRef, vm]); diff --git a/src/sound/screen_share_started.mp3 b/src/sound/screen_share_started.mp3 new file mode 100644 index 00000000..5a4113f9 Binary files /dev/null and b/src/sound/screen_share_started.mp3 differ diff --git a/src/sound/screen_share_started.ogg b/src/sound/screen_share_started.ogg new file mode 100644 index 00000000..1a3f0c1d Binary files /dev/null and b/src/sound/screen_share_started.ogg differ diff --git a/src/state/CallViewModel.ts b/src/state/CallViewModel.ts index af59c3b2..d11db164 100644 --- a/src/state/CallViewModel.ts +++ b/src/state/CallViewModel.ts @@ -1202,6 +1202,21 @@ export class CallViewModel extends ViewModel { }), this.scope.state(), ); + /** + * Emits an event every time a new screenshare is started in + * the call. + */ + public readonly newScreenShare$ = this.screenShares$.pipe( + map((v) => v.length), + scan( + (acc, newValue) => ({ + value: newValue, + playSounds: newValue > acc.value, + }), + { value: 0, playSounds: false }, + ), + filter((v) => v.playSounds), + ); public readonly reactions$ = this.reactionsSubject$.pipe( map((v) =>