Quantcast
Channel: Dynamically loading and autoplaying HTML5 video - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Dynamically loading and autoplaying HTML5 video

$
0
0

I am trying to grab a video URL from data-src and add it to src for my video. I have that much working when I snoop the page code but the video isn't showing up on the page and playing. I'm using jQuery since I have a few other bits of code using it to run some functionality.

Markup:

<video autoplay="autoplay" loop="loop" poster="/assets/video/bg-ss-vid.jpg"><source type="video/mp4" data-src="/assets/video/bg-ss-vid.mp4"></video>

jQuery:

jQuery(document).ready(function ($) {"use strict";    $("#site-hero video").each(function () {        $('source', $(this)).attr("src", $('source', $(this)).data('src'));        $('source', $(this)).removeAttr('data-src');    });});

How do I get it to show up / play the video after the src has been loaded?


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>