mirror of
https://github.com/basnijholt/compose-farm.git
synced 2026-02-03 06:03:25 +00:00
22 lines
556 B
JavaScript
22 lines
556 B
JavaScript
// Fix Safari video autoplay issues
|
|
(function() {
|
|
function initVideos() {
|
|
document.querySelectorAll('video[autoplay]').forEach(function(video) {
|
|
video.load();
|
|
video.play().catch(function() {});
|
|
});
|
|
}
|
|
|
|
// For initial page load (needed for Chrome)
|
|
if (document.readyState === 'loading') {
|
|
document.addEventListener('DOMContentLoaded', initVideos);
|
|
} else {
|
|
initVideos();
|
|
}
|
|
|
|
// For MkDocs instant navigation (needed for Safari)
|
|
if (typeof document$ !== 'undefined') {
|
|
document$.subscribe(initVideos);
|
|
}
|
|
})();
|