aboutsummaryrefslogtreecommitdiff
path: root/webAO/viewport/utils/createBlipChannels.ts
diff options
context:
space:
mode:
Diffstat (limited to 'webAO/viewport/utils/createBlipChannels.ts')
-rw-r--r--webAO/viewport/utils/createBlipChannels.ts15
1 files changed, 15 insertions, 0 deletions
diff --git a/webAO/viewport/utils/createBlipChannels.ts b/webAO/viewport/utils/createBlipChannels.ts
new file mode 100644
index 0000000..6296b3b
--- /dev/null
+++ b/webAO/viewport/utils/createBlipChannels.ts
@@ -0,0 +1,15 @@
+import { opusCheck } from "../../dom/opusCheck";
+
+export const createBlipsChannels = () => {
+ const blipSelectors = document.getElementsByClassName(
+ "blipSound"
+ ) as HTMLCollectionOf<HTMLAudioElement>;
+
+ const blipChannels = [...blipSelectors];
+ // Allocate multiple blip audio channels to make blips less jittery
+ blipChannels.forEach((channel: HTMLAudioElement) => (channel.volume = 0.5));
+ blipChannels.forEach(
+ (channel: HTMLAudioElement) => (channel.onerror = opusCheck(channel))
+ );
+ return blipChannels;
+}; \ No newline at end of file