Reputation: 12369
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.
Upvotes: 4
Views: 11783
Reputation: 122
Faced the same issue recently, ios happens to block the autoplay due to battery/power saving mode scenarios. Tried everything but the below combination 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>
Upvotes: 1
Reputation: 25471
I 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 becomes 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 become non-visible, such as by being scrolled out of the viewport.
Source: https://webkit.org/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:
Upvotes: 4