I’ve added code, to a digital magazine site I’ve created, that enables me to play audio (via a button widget). While in preview mode, this audio works and the published version works for me locally. However, the audio doesn’t work externally (on mobile).
Essentially, the code appears to work. And because of this, I’m wondering if the issue we’re experiencing is related to browsers blocking the audio from playing.
Has anyone experienced issues with browsers blocking audio?
While I don’t think the code is the issue here, the code I’m using to play the audio is below.
A truncated version of the site I’ve developed is here: Zoo News - Forum enq | Readymag
I’m hoping someone might be able to shed some light on this issue.
<script>
var audio = new Audio("https://www.dropbox.com/scl/fi/1cqu0upxrq2toode02zc6/Siamang.mp3?rlkey=kaz5102qjge3co581gf7ebugh&st=so1p80pf&dl=1");
function togglePlay() {
return audio.paused ? audio.play() : audio.pause();
};
$('div.common-button[data-id="666a97049bde2a004bad6f63"]').click( togglePlay );
</script>