Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autoplay audio files on an iPad with HTML5

I'm trying to get an audio file to autoplay in Safari on an iPad. If I go to the page using Safari on my Mac, it's fine. On the iPad, autoplay does not work.

like image 840
milesmeow Avatar asked Jun 09 '10 20:06

milesmeow


People also ask

How do I enable Autoplay on my iPad?

Click on Safari > Preferences on the top menu. Click on the Websites tab at the top. Click on Auto-Play in the left column.

How do I autoplay audio in HTML?

The simplest way to automatically play content is to add the autoplay attribute to your <audio> or <video> element.

How do I autoplay audio in HTML Chrome?

Just add an invisible iframe with an . mp3 as its source and allow="autoplay" before the audio element. As a result, the browser is tricked into starting any subsequent audio file. Or autoplay a video that isn't muted.

How to Auto Play videos and audios on iOS devices?

you can't auto-play videos and audios on iOS in normal mode, you may use trick like simulate user input to auto-play videos and audios. In Safari on iOS (for all devices, including iPad), where the user may be on a cellular network and be charged per data unit, preload and autoplay are disabled. No data is loaded until the user initiates it.

Why doesn't AutoPlay work on iPad?

Autoplay doesn't work on the iPad or iPhone for either the video or the audio tags. This is a restriction set in place by Apple to save the users bandwidth. It seems to me that the answer to this question is (at least now) clearly documented on the Safari HTML5 docs:

What is the HTML <audio> AutoPlay attribute?

HTML <audio> autoplay Attribute 1 Definition and Usage. The autoplay attribute is a boolean attribute. When present, the audio will automatically start... 2 Browser Support. The numbers in the table specify the first browser version that fully supports the attribute. 3 Syntax. More ...

How do I launch AutoPlay audio from a website?

The three way of launching autoplay audio are: Simply having an <audio> element in the page HTML Adding an <audio> element to the DOM via jQuery Creating audio with new Audio() .


1 Answers

I would like to also emphasize that the reason you cannot do this is a business decision that Apple made, not a technical decision. To wit, there was no rational technical justification for Apple to disable sound from web apps on the iPod Touch. That is a WiFi device only, not a phone that may incur expensive bandwidth charges, so that argument has zero merit for that device. They may say they are helping with WiFi network management, but any issues with bandwidth on my WiFi network is my concern, not Apple's.

Also, if what they really cared about was preventing unwanted, excessive bandwidth consumption, they would provide a setting to allow users to opt-in to web apps sounds. Also, they would do something to restrict web sites from consuming equivalent bandwidth by other means. But there are no such restrictions. A web site can download huge files in the background over and over and Apple could care less about that. And finally, I believe the sounds can be downloaded anyway, so NO BANDWIDTH IS ACTUALLY SAVED! Apple just does not allow them to play automatically without user interaction, making them unusable for games, which of course is their real intent.

Apple blocked sound because they started to notice that HTML5 apps can be just as capable as native apps, if not more so. If you want sound in Web Apps you need to lobby Apple to stop being anti-competitive like Microsoft. There is no technical problem that can be fixed here.

like image 184
Rick M Avatar answered Sep 27 '22 23:09

Rick M