I attempted to play a very small and short mp3 file (5kb, 200ms) using JavaScript and looping it with setInterval. It functions smoothly on desktop browsers without any issues.
However, when I try to play the same file on a mid-range android phone (both browser and app webview), as well as android emulators such as Nox player and Android Studio Emulator, it sometimes skips during playback. Additionally, the rhythm is not consistent and there are delays of a few milliseconds at times.
If I switch to an even smaller audio file (1kb, 100ms), the skipping issue disappears but the timing is still inconsistent. The code I am using is quite simple (see below). Can you suggest any optimizations to ensure it plays with precise timing and without dropping?
var tap_sound = new Audio("/audio/tap2.mp3");
tap_looping_Job = setInterval(() => {
tap_sound.play();
}, 400);