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.
This commit is contained in:
David Négrier 2021-06-03 14:53:58 +02:00
parent 46cd387853
commit 80a698d891
1 changed files with 10 additions and 2 deletions

View File

@ -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 {