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()">`
ChromeSamples.log('Attempting to play automatically...');
startPlayback().then(function() { ChromeSamples.log('The play() Promise fulfilled! Rock on!'); }).catch(function(error) { ChromeSamples.log('The play() Promise rejected!'); ChromeSamples.log('Use the Play button instead.'); ChromeSamples.log(error);
var playButton = document.querySelector('#play'); // The user interaction requirement is met if // playback is triggered via a click event. playButton.addEventListener('click', startPlayback); playButton.hidden = false; });