How to play audio using Java Script on IPad?

167 Views Asked by At

I am trying to implement functionality to play an audio using Java Script. Its working fine on Google Chrome, Firefox and Other Browser. But when I try to play sound on iPad or iPhone or MAC I am getting below error.

Unhandled Promise Rejection: NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.

Below is my Sample Code.

var APlayer = document.createElement("AUDIO");

APlayer.setAttribute("controls", "controls");

APlayer.src = audioUrl;

APlayer.play();

Can any body help me to find out the solution.

0

There are 0 best solutions below