Audio tag on Iphone (Safari)

28 Views Asked by At

I am making a barcode scanning web application. I chose QuaggaJS as barcode scanning library. I want to play a beep sound when the barcode is scanned. I have used audio tag and using JQuery to play the sound on detection of barcode. It works for all the broswers such as Chrome, Edge, FireFox but it does not work well on Safari. Other events also triggers the play() unexpectedly. Sometimes it works and sometimes it does not.

Code:

Audio

<audio id="beepSound" controls>
    <source src="beep.mp3" type="audio/mp3"/>
    <source src="beep.ogg" type="audio/ogg" />
</audio>

JQuery :

Quagga.onDetected(function (result) {
    $('#beepSound').get(0).load();
    $("#beepSound").get(0).play();
    Quagga.stop();
});

I have tried most of the solutions provided on StackOverflow for this issue but none seems to work. Even tried using this Html 5 Audio is not working in iphone safari browser but it did not work.

0

There are 0 best solutions below