Stop HTML Video Autoplay on Mobile Devices
$(document).ready
only begins AFTER the page is loaded, thus the browser has already began the autoplay.
Instead, you should remove the autoplay
attribute from the static HTML, and only add it then if the width is greater than 800.
<video id="background-video" loop muted>
<source type="video/mp4" src="http://fiercefreedom.org/wp-content/uploads/2018/10/FierceCropped.mp4">
</video>
$(function() {
var screenWidth = $(window).width();
if (screenWidth >= 800) {
$('#background-video').attr('autoplay', 'autoplay');
}
});
HTML5 Video autoplay on Mobile Browser
Since the release of iOS 10 Apple has allowed muted video autoplay: https://webkit.org/blog/6784/new-video-policies-for-ios/
Chrome 53 on Android also allowing muted video autoplay: https://developers.google.com/web/updates/2016/07/autoplay
Related Topics
CSS 100% Height, and Then Scroll Div Not Page
CSS Grid with Variable Number of "Auto" Rows, But One Row Should Take "1Fr"
How to Use Nth-Child for Styling with a Table with Rowspan
CSS Border on Png Image with Transparent Parts
How to Prefix Ordered List Item Numbers with a Static String Using CSS
What Are The Default Values for Justify-Content & Align Content
How to Select Multiple Elements in The Chrome Developer Tools Elements Panel
CSS Changes Are Not Getting Reflected. Why
Is There a Jdk Class to Do HTML Encoding (But Not Url Encoding)
How to Add a Google Search Box to My Website
Align Images Side by Side in HTML
Placeholder Not Working for Internet Explorer
Bootstrap 4 Order Masonry-Like Column Cards Horizontal Instead of Vertical