From be2fc0c0260b2ed19b2deb3c537f733e6505dc91 Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Wed, 8 Feb 2023 21:23:08 -0800 Subject: [PATCH] Safer AudioContext access --- web/static/js/BareRTC.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/web/static/js/BareRTC.js b/web/static/js/BareRTC.js index 1521b96..46c3afe 100644 --- a/web/static/js/BareRTC.js +++ b/web/static/js/BareRTC.js @@ -969,11 +969,14 @@ const app = Vue.createApp({ */ setupSounds() { - if (AudioContext) { - this.config.sounds.audioContext = new AudioContext(); - } else { - this.config.sounds.audioContext = window.AudioContext || window.webkitAudioContext; - } + try { + if (AudioContext) { + this.config.sounds.audioContext = new AudioContext(); + } else { + this.config.sounds.audioContext = window.AudioContext || window.webkitAudioContext; + } + } catch {} + if (!this.config.sounds.audioContext) { console.error("Couldn't set up AudioContext! No sound effects will be supported."); return;