I know that there is a limitation in iOS Safari where the audio is not playing until user triggers an interaction. So I have placed the code inside a
touchstart
event, but that does not cause the API to start playing.I have also seen other questions in StackOverflow regarding this issue, and I have also tried a bunch of other tweaks including:
- putting the audio load outside the
callbacktouchstart
- try adding a gain node
- use 0.01 as the start time
and none of the above works in iOS Safari, but the audio plays OK in desktop Chrome and Safari. I can confirm the audio source has loaded fine, I can also confirm that the code has executed the play step, but nothing gets played.
Here is the link to the gist, you can see the versions where I made the changes (P.S. the click event is used for testing on desktop)
https://gist.github.com/angelathewebdev/32e0fbd817410db5dea1