Skip to content Skip to sidebar Skip to footer

Playing Html5 Audio In Ajax Response In Ios

After a lot of googling and researching, I have found out that iOS blocks autoplaying of html5 audio and video. Audio and Video can only be played as a response to a click event.

Solution 1:

I know this is an ancient question, but for people coming across this there is a straightforward solution which is to play a short, silent sound directly from the click handler. Ideally, this would be a sound file you have already fetched and cached.

After that you'll be able to initiate playback from other handlers, even those without direct user interaction. (such as your AJAX/XHR response)

Solution 2:

Okay, after a bit of fooling around and researching, I figured out that the only way to do a playlist fetch and play in one click, is to use a synchronous request instead of an AJAX request. The page will freeze up while the request loads, but it seems to be the only way out.

Post a Comment for "Playing Html5 Audio In Ajax Response In Ios"