I have seen Why can't JavaScript .play() audio files on iPhone safari? and I know that a user interaction is required before playing an audio object. However, this doesn't work on iOS 14:
<div id="a">Click here</div>
<script>
var audio = new Audio('a.mp3');
audio.load();
document.getElementById('a').onclick = function() {
audio.pause(); // always restart the sound, see https://stackoverflow.com/a/13243338
audio.currentTime = 0;
audio.play();
}
</script>
With this code, no sound is produced which clicking/touching on the <div>, with an iPhone on iOS 14.
How to solve this?