Safer AudioContext access

ipad-testing
Noah 2023-02-08 21:23:08 -08:00
parent a55b4b2b49
commit be2fc0c026
1 changed files with 8 additions and 5 deletions

View File

@ -969,11 +969,14 @@ const app = Vue.createApp({
*/ */
setupSounds() { setupSounds() {
if (AudioContext) { try {
this.config.sounds.audioContext = new AudioContext(); if (AudioContext) {
} else { this.config.sounds.audioContext = new AudioContext();
this.config.sounds.audioContext = window.AudioContext || window.webkitAudioContext; } else {
} this.config.sounds.audioContext = window.AudioContext || window.webkitAudioContext;
}
} catch {}
if (!this.config.sounds.audioContext) { if (!this.config.sounds.audioContext) {
console.error("Couldn't set up AudioContext! No sound effects will be supported."); console.error("Couldn't set up AudioContext! No sound effects will be supported.");
return; return;