Last active
December 22, 2015 21:40
-
-
Save jramsahai/3dd2ad6d678a097c6e4f to your computer and use it in GitHub Desktop.
Modified version of https://gist.github.com/jramsahai/a1cf80fdf0e9116b79da where a secondary generic player is shown instead of the personalized player if no custom_id is given.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<style type="text/css"> | |
#innerContainer { | |
position: relative; | |
display: block; | |
width: 100% !important; | |
height: 0; | |
padding: 56.25% 0 0 0; /* This should reflect your video aspect ratio */ | |
} | |
#outerContainer { | |
max-height: 360px; /* Set this to the height of your player */ | |
} | |
.vidyard_player { | |
position: absolute; | |
top: 0; | |
left: 0; | |
width: 100%; | |
height: 100%; | |
max-width: 640px; /* These should be the dimensions of your player */ | |
max-height: 360px; | |
} | |
.vidyard_player > span { | |
width: 100% !important; | |
height: 100% !important; | |
margin: 0 auto !important; | |
} | |
</style> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> | |
</head> | |
<body> | |
<div id="outerContainer"> | |
<div id="innerContainer"></div> | |
</div> | |
<script type="text/javascript"> | |
// Parsing the query string | |
function get_parameter_by_name(name) { | |
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); | |
var regexS = "[\\?&]" + name + "=([^&#]*)"; | |
var regex = new RegExp(regexS); | |
var results = regex.exec(window.location.search); | |
if (results == null) { | |
return ""; | |
} else { | |
return results[1]; | |
} | |
} | |
// Read the custom ID that was merged into the campaign email as a query string parameter | |
// Parameter should be "custom_id" e.g. http://www.landingpage.com?custom_id={merge field value} | |
var videoID = get_parameter_by_name('custom_id'); | |
if (videoID[videoID.length-1] == "/") { | |
videoID = videoID.substring(0,videoID.length-1); | |
} | |
// This section generates the embed code for your personalized player | |
// If no custom_id is specified a different, a generic player is dislayed | |
// Replace "arlhtoDOr-y4rGm-eXnOFA" with the UUID of the GENERIC player. | |
// Replace "UZYe4k2NcadCDL8cnk2K1w" with the UUID of the PERSONALIZED player. | |
// Add "preview=1" to embedScript.src to test the loading of the individual videos | |
var embedScript=document.createElement('script'); | |
embedScript.type='text/javascript'; | |
if (videoID == "") { | |
embedScript.id='vidyard_embed_code_arlhtoDOr-y4rGm-eXnOFA'; | |
embedScript.src='//play.vidyard.com/arlhtoDOr-y4rGm-eXnOFA.js?v=3.1.1&type=inline&'; | |
} else { | |
embedScript.id='vidyard_embed_code_UZYe4k2NcadCDL8cnk2K1w'; | |
embedScript.src='//play.vidyard.com/UZYe4k2NcadCDL8cnk2K1w.js?v=3.1.1&type=inline&custom_id='+videoID; | |
} | |
$("#innerContainer").append(embedScript); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment