Video Streaming Embed Code

#1

If I have multiple videos embedded on one page, do I need include the .js file more than once?

Each embed code is like this:

<stream src="####" controls></stream>
<script data-cfasync="false" defer type="text/javascript" src="https://embed.videodelivery.net/embed/r4xu.fla9.latest.js?video=####"></script>

But if I have multiple videos, can I not just put the <stream> tag for each video and then only include the <script> once? I might be wrong, but I really do not see anything in the .js file that is using that video query string… and including it more than once might be causing load time and page size issues…

0 Likes

#2

Dunno…give it a try and let us know how it goes. But I bet it breaks. The script includes the stream ID. No script…no play.

0 Likes

#3

The script does include the stream ID, but does not appear to use it…

Which, I just tested this, and it works fine with just calling the script once while having multiple stream elements on one page.

Each video loads as expected.

1 Like

#4

I’m glad I didn’t put any money on that bet. :smile:

0 Likes

#5

In fact, what I did was this:

I only include the stream tag in the HTML where I want to embed the video… and then in the footer of all pages, I have this

<script>
(function() {
  if(document.getElementsByTagName("stream").length > 0) {
    var script= document.createElement("script");
    script.type= "text/javascript";
    script.defer = "defer";
    script.src= "https://embed.videodelivery.net/embed/r4xu.fla9.latest.js";
    document.getElementsByTagName("body")[0].appendChild(script);
  }
}());
</script>

So if there are any stream tags, it automatically loads the javascript… and if there are none, it does not.

1 Like