Skip to content

Instantly share code, notes, and snippets.

@jramsahai
Last active March 17, 2022 17:05
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jramsahai/2560966138cfd69d9ea6 to your computer and use it in GitHub Desktop.
A slight modification to this: https://gist.github.com/jramsahai/040be6747bf60f207337. This one will allow you to load multiple players in different locations on the page on demand.
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript">
// Generate and return embed code for a given player UUID
function getEmbedCode(uuid) {
var script=document.createElement('script');
script.type='text/javascript';
script.id='vidyard_embed_code_'+uuid;
script.src='//play.vidyard.com/'+uuid+'.js?v=3.1.1&type=inline&autoplay=0';
return script;
}
function loadPlayer(modalid,uuid) {
document.getElementById(modalid).innerHTML = "";
// Get embed code and embed and execute it in the right spot on the page
$("#"+modalid).append(getEmbedCode(uuid));
}
function unloadPlayer(uuid) {
$("#vidyard_iframe_"+uuid).remove();
$("#vidyard_span_"+uuid).remove();
$("#vidyard_"+uuid).remove();
$("#vidyard_embed_code_"+uuid).remove();
}
</script>
</head>
<body>
<div style="height: 360px;">
<div id="video_container01"></div>
</div>
<a href="javascript:void(0);" onclick="loadPlayer('video_container01','CzRrg-_qv1UX6EVcc9nO6w');">Load Video</a><br />
<a href="javascript:void(0);" onclick="unloadPlayer('CzRrg-_qv1UX6EVcc9nO6w');">Destroy Video</a>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment