From 6f7e409e9a655c619e9584a9f5ffea9adaa70d9d Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 3 Dec 2020 17:41:34 +0000 Subject: [PATCH] Some little fixes to support line 1 / 2 * Resume playing audio at the appropriate time * Re-emit call events (they were the exception before - all other events were re-emitted through the MatrixClient) * Fix an audio/video typo --- src/webrtc/call.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/webrtc/call.ts b/src/webrtc/call.ts index 7667243d4..ed8efd55d 100644 --- a/src/webrtc/call.ts +++ b/src/webrtc/call.ts @@ -457,9 +457,7 @@ export class MatrixCall extends EventEmitter { async setRemoteAudioElement(element: HTMLAudioElement) { if (element === this.remoteAudioElement) return; - if (this.remoteVideoElement) this.remoteVideoElement.muted = true; this.remoteAudioElement = element; - this.remoteAudioElement.muted = false; if (this.remoteStream) this.playRemoteAudio(); } @@ -686,6 +684,10 @@ export class MatrixCall extends EventEmitter { } this.updateMuteStatus(); + if (!onHold) { + this.playRemoteAudio(); + } + this.emit(CallEvent.RemoteHoldUnhold, this.remoteOnHold); } @@ -1265,6 +1267,9 @@ export class MatrixCall extends EventEmitter { playRemoteAudio() { this.queueMediaOperation(MediaQueueId.RemoteAudio, async () => { + if (this.remoteVideoElement) this.remoteVideoElement.muted = true; + this.remoteAudioElement.muted = false; + this.remoteAudioElement.srcObject = this.remoteStream; // if audioOutput is non-default: @@ -1284,7 +1289,7 @@ export class MatrixCall extends EventEmitter { try { await this.remoteAudioElement.play(); } catch (e) { - logger.error("Failed to play remote video element", e); + logger.error("Failed to play remote audio element", e); } }); } @@ -1628,5 +1633,9 @@ export function createNewMatrixCall(client: any, roomId: string, options?: CallO // call level options forceTURN: client._forceTURN || optionsForceTURN, }; - return new MatrixCall(opts); + const call = new MatrixCall(opts); + + client.reEmitter.reEmit(call, Object.values(CallEvent)); + + return call; }