From 955c663bc52615fd9d538dfb73557092df8beed3 Mon Sep 17 00:00:00 2001 From: Half-Shot Date: Thu, 19 Dec 2024 12:03:09 +0000 Subject: [PATCH] Add screen share sound effect. --- src/state/CallViewModel.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/state/CallViewModel.ts b/src/state/CallViewModel.ts index d11db164..49b2416b 100644 --- a/src/state/CallViewModel.ts +++ b/src/state/CallViewModel.ts @@ -1288,6 +1288,22 @@ export class CallViewModel extends ViewModel { filter((v) => v.playSounds), ); + /** + * 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 constructor( // A call is permanently tied to a single Matrix room and LiveKit room private readonly matrixRTCSession: MatrixRTCSession,