Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery / Javascript Video Replace
    primarykey
    data
    text
    <p>Ok, so I'm obviously missing something here (just can't figure out what it is I'm missing). I've been working on a basic script to take the contents of divs like so:</p> <pre><code>&lt;div class="sxvideo"&gt;1745623935001,640,360&lt;/div&gt; &lt;div class="sxvideo"&gt;1745605281001&lt;/div&gt; &lt;div class="sxvideo"&gt;1745623933001,900&lt;/div&gt; </code></pre> <p>and then I have this (loaded at the bottom of the page) to take the innerHTML (which is the video ID, width, and height) swap them out, .split the data by comma, make sure that both the height and width aren't left undefined, and then replace the innerHTML with the full embed code, dropping the variables into the right places:</p> <pre><code>&lt;script language="JavaScript" type="text/javascript" src="http://admin.brightcove.com/js/BrightcoveExperiences.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $("div.sxvideo").each(function () { "use strict"; var bcid = this.innerHTML.split(","); if (bcid[1] === undefined) { bcid[1] = "720"; } if (bcid[2] === undefined) { bcid[2] = "404"; } this.innerHTML = '&lt;center&gt;&lt;div style="margin-bottom:15px; height: ' + bcid[2] + 'px; width: ' + bcid[1] + 'px;"&gt;&lt;object id="myExperience' + bcid[0] + '" class="BrightcoveExperience"&gt;&lt;param name="bgcolor" value="#172531" /&gt;&lt;param name="width" value="' + bcid[1] + '" /&gt;&lt;param name="height" value="' + bcid[2] + '" /&gt;&lt;param name="playerID" value="68593058001" /&gt;&lt;param name="playerKey" value="AQ~~,AAAACmfZzQE~,c2ejuULn_boEBJAb-NiqNIQuC2o543gE" /&gt;&lt;param name="isVid" value="true" /&gt;&lt;param name="isUI" value="true" /&gt;&lt;param name="dynamicStreaming" value="true" /&gt;&lt;param name="@videoPlayer" value="' + bcid[0] + '" /&gt;&lt;/object&gt;&lt;/div&gt;&lt;/center&gt;'; }); &lt;/script&gt; &lt;script type="text/javascript"&gt;brightcove.createExperiences();&lt;/script&gt; </code></pre> <p>EDITED ADDITIONS: In order to clear things up a little bit (and this might be the issue), the embed code takes the info then calls the video up by script (which is what the last line brightcove.createExperiences() does). The embed code is fine. If I take that format and post that (replacing the variables with data), it works fine and loads the video. </p> <p>Is it because I'm calling the brightcove .js outside the script? I wanted to replace each instance of , THEN call brightcove.createExperiences(), not replace the content and call it for every div (you only have to call it once per page). </p> <p>Should it be written with a document ready to make sure it's done in the proper order? Brain scrambled.</p> <p>Or, if anyone has a better suggestion on how to do this more efficiently/better, feel free to post it here. Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload