1

I am trying to make a web HTML/JS cliker game - however I have come across an issue on iOS that doesn't seem to be an issue on Android.

Basically, whenever the player clicks or taps, a sound is played. On android, you can tap or click rapidly and the sound plays just fine. If you try on iOS, the game seems to bog and Safari seems to struggle with handling all the sounds.

I've seen solutions (such as this one) that speak about AudioContext etc but I cannot wrap my head around how it works. Here is my code that handles the click and sound;

$('#clickElement').on('click', function() { 
    //Play Sound
    const AudioContext = window.AudioContext || window.webkitAudioContext;
    const audioCtx = new AudioContext();
    var clickSound = new Audio('../Sounds/Click.mp3');
    clickSound.currentTime = 0;
    clickSound.play();
});

Some help understanding how to properly implement AudioContext would be fantastic!

Thanks!

N0tSp4m
  • 39
  • 4

0 Answers0