Reputation: 21
I have an HTML5 app that's essentially a soundboard. You click an image and it plays an mp3 file. It works fine on Chrome but not on my iPad Safari. The function looks like this:
<script type="text/javascript">
function playSound(theSound) {
soundDir = "./sounds/";
filename = soundDir + theSound;
sound = new Audio(soundDir + theSound);
sound.setAttribute("autoplay", "autoplay");
document.getElementsByTagName("body")[0].appendChild(sound);
return true;
}
</script>
And it's called like this:
onclick=playSound("knife.mp3")
What am I doing wrong?
Upvotes: 2
Views: 2794
Reputation: 11
More extensive research showed me that 1) Apple doesn't seem to like "autoplay" for bandwidth reasons, and 2) the jPlayer people are smarter than I am and have it working already.
Upvotes: 1