Last active
October 2, 2025 13:55
-
-
Save jenswittmann/226504373a0083156d52aaff8a7c1064 to your computer and use it in GitHub Desktop.
HTML5 Video Autoplay in Safari, Chrome und Co. for 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php if (preg_match('/safari/i', $_SERVER['HTTP_USER_AGENT']) && !preg_match('/chrome/i', $_SERVER['HTTP_USER_AGENT'])): ?> | |
| <!-- Docs: https://developer.apple.com/documentation/webkit/delivering-video-content-for-safari#Use-MP4-Video-Instead-of-Animated-GIFs --> | |
| <img | |
| src="video.mp4" | |
| width="1600" | |
| height="900" | |
| alt="" /> | |
| <?php else: ?> | |
| <video | |
| src="video.mp4" | |
| width="1600" | |
| height="900" | |
| autoplay | |
| muted | |
| loop | |
| playsinline></video> | |
| <?php endif ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment