Jean-Baptiste Bouhier Jean-Baptiste Bouhier - 5 months ago 126
iOS Question

How to autoplay HTML5 <video> and <audio> tags on iOS ?

My team and I are tying to make a web application autoplay HTML5 video/audio tags on iPad. So far no luck after many attempts with CSS and JavaScript.


The question is: What other option is there to make it autoplay ?


I'm thinking native app with integrated browser with iOS API calls to simulate a touch/click and thus making the video/audio tags autoplay.

Is it possible and if yes, how and with which iOS version ?

Thanks

Answer

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.

Safari HTML5 Audio and Video Guide

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. This means the JavaScript play() and load() methods are also inactive until the user initiates playback, unless the play() or load() method is triggered by user action. In other words, a user-initiated Play button works, but an onLoad="play()" event does not.

This plays the movie: <input type="button" value="Play" onclick="document.myMovie.play()">

This does nothing on iOS: <body onload="document.myMovie.play()">