Simon Davies
Simon Davies

Reputation: 3684

iPad Audio autoplay

I want a simple audio file to play when a web page loads.

  var myaudio = new audio("file path .mp3");
  myaudio.play()

this works on all the usual browser chrome etc onload but does not play on the ipad, to init this sound I need to use say a onPress function and place the .play code within there and it plays fine.

So how can I have the fiel play onload and nto have a user init via a click? I beleive the mobile safari prevents autoplay but not sure?

Thanks

Upvotes: 0

Views: 3775

Answers (1)

Ian Devlin
Ian Devlin

Reputation: 18870

You can't automatically play an audio file on the iPad, this is a design decision by Apple. There might be some way around it of course, but autoplaying audio and video is usually not recommended.

See here: iOS-Specific Considerations (under "User Control of Downloads Over Cellular Networks").

Upvotes: 2

Related Questions