All of my research and effort has been hitting a wall so far in this regard: Is there any way to make video autoplay on Safari in iOS currently?
Some have mentioned video transcoding or using playsinline
(which works on Android), but nothing has worked for iOS / Safari.
EDIT: Updated title for 2024 since we've got a new answer that could be helpful.
All of my research and effort has been hitting a wall so far in this regard: Is there any way to make video autoplay on Safari in iOS currently?
Some have mentioned video transcoding or using playsinline
(which works on Android), but nothing has worked for iOS / Safari.
EDIT: Updated title for 2024 since we've got a new answer that could be helpful.
Share Improve this question edited May 16, 2024 at 19:18 ylluminate asked Jul 7, 2020 at 16:57 ylluminateylluminate 12.4k17 gold badges82 silver badges161 bronze badges 1- Apple have done a pretty good job of blocking this in most scenarios (conserves battery and bandwidth) until the user interacts with an element... can't think of a reliable working example that I've seen for a while – Offbeatmammal Commented Jul 7, 2020 at 23:49
2 Answers
Reset to default 4I believe the following is still the current picture for iOS:
elements will now honor the autoplay attribute, for elements which meet the following conditions:
- elements will be allowed to autoplay without a user gesture if their source media contains no audio tracks.
- elements will also be allowed to autoplay without a user gesture.
- If a element gains an audio track or bees un-muted without a user gesture, playback will pause.
- elements will only begin playing when visible on-screen such as when they are scrolled into the viewport, made visible through CSS, and inserted into the DOM.
- elements will pause if they bee non-visible, such as by being scrolled out of the viewport.
Source: https://webkit/blog/6784/new-video-policies-for-ios/
This also requires that the video element has the playsinline
attribute.
So there is support for autoplay video, but it is limited so may not meet your particular needs.
One other note - if your use case is for a web view rather than a regular browser, then you have more control. See the documentation for wkwebviewconfiguration
and in particular mediaTypesRequiringUserActionForPlayback
here:
- https://developer.apple./documentation/webkit/wkwebviewconfiguration
Faced the same issue recently, ios happens to block the autoplay due to battery/power saving mode scenarios. Tried everything but the below bination seemed to be working fine for me. Apart from the muted & playsInline try adding type="" in your source.
<video loop autoPlay muted playsInline>
<source src="" type="video/mp4"/>
</video>