From 80a698d89127b7ddf44a5117d11e9ccb495375eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 3 Jun 2021 14:53:58 +0200 Subject: [PATCH] Preventing crash on iOS On iOS, audio elements must be triggered by a user gesture. We are catching exceptions thrown in order not to crash. In the future, we need to find another way to play sounds. --- front/src/WebRtc/MediaManager.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/front/src/WebRtc/MediaManager.ts b/front/src/WebRtc/MediaManager.ts index 7b527962..7cdf1de0 100644 --- a/front/src/WebRtc/MediaManager.ts +++ b/front/src/WebRtc/MediaManager.ts @@ -129,7 +129,11 @@ export class MediaManager { } addActiveVideo(user: UserSimplePeerInterface, userName: string = ""){ - this.webrtcInAudio.play(); + try { + this.webrtcInAudio.play(); + } catch(e) { + console.error(e); + } const userId = ''+user.userId userName = userName.toUpperCase(); @@ -278,7 +282,11 @@ export class MediaManager { } playWebrtcOutSound(): void { - this.webrtcOutAudio.play(); + try { + this.webrtcOutAudio.play(); + } catch(e) { + console.error(e); + } } isConnecting(userId: string): void {