Skip to content

Instantly share code, notes, and snippets.

@jramsahai
Created September 30, 2014 14:35
Show Gist options
  • Save jramsahai/040be6747bf60f207337 to your computer and use it in GitHub Desktop.
Save jramsahai/040be6747bf60f207337 to your computer and use it in GitHub Desktop.
Depending on the number of players you are planning on displaying on your page, it might be a good idea to avoid loading every single player when the page loads. Creating all of those Flash objects at once can really slow things down. Here's a suggestion on how you can dynamically load an inline player. This example also shows how to change the …
<htmL>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript">
function getEmbedCode(uuid) {
var script=document.createElement('script');
script.type='text/javascript';
script.id='vidyard_embed_code_'+uuid;
script.src='https://play.vidyard.com/'+uuid+'.js?v=3.1&type=inline';
return script;
}
function changePlayer(uuid) {
document.getElementById("video_container").innerHTML = "";
$("#video_container").append(getEmbedCode(uuid));
}
</script>
</head>
<body>
<script type="text/javascript">
window.onload = function() {
$("#video_container").append(getEmbedCode('dUY0t4jCa7QMInasnyucPg'));
};
</script>
<div style="height: 400px;">
<div id="video_container"></div>
</div>
<a href="javascript:void(0);" onclick="changePlayer('WWr1fWRS-Zei6Ztn1ayMsQ');">Change video</a>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment