I have some code to change the src attr of a video on mobile. It looks like this:
<div class="product-video--mobile swiper-slide">
<video class="product-video"
src="{{ variant.metafields.Details.videoMobileURL }}"
width="100%"
type="video/mp4"
loop muted playsinline autoplay
data-video-src="{{ variant.metafields.Details.videoMobileURL }}"
alt="product-video"></video>
</div>
JS:
$(".product-video--mobile .product-video").attr("src", $(".active-video").data("mobile-video-variant"));
On desktop, this code seems to work fine but on iOS, it stops playing.
Per these answers:
Video autoplay doesn't work on all iphone
HTML5 Video autoplay on iPhone
HTML5 Video Background not playing Safari on iPhone
I have both playsinline
and muted
attributes on my video tag, but it still won't autoplay. Is it because I changed the source?