aboutsummaryrefslogtreecommitdiff
path: root/webAO/viewport/utils/createBlipChannels.ts
blob: 6296b3b1a56a2eae170b42b123ff45251da5d6c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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;
};