Overview
You may have a requirement to send a link to a player, but also ensure that when the player begins to play, it starts at a certain point.
This could be useful for a long video where only a particular scene is relevant for the contact to watch.
Solution
You can use the Vidyard API JavaScript and some additional code to read a timecode from the URL for a specific player on your page. Simply paste the code below into the body of your page HTML and replace each mention of <UUID> with the player UUID.
This code includes the player embed--shown in bold. You can remove this piece if you already have a player on your page and then paste the remaining code underneath.
<!-- Vidyard inline embed code --> <script type="text/javascript" id="vidyard_embed_code_<UUID>" src="//play.vidyard.com/<UUID>.js?v=3.1&type=inline"></script> <script src="//play.vidyard.com/v0/api.js"></script> <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]; } } // Get the number of seconds from the query string using "vytime" as the parameter var urlParam = get_parameter_by_name("vytime"); var playerTime = Number(urlParam); // If the vytime parameter is present, start the video automatically and jump to the time. function timeCheck() { if (playerTime > 0) { // Use the player API to start the player and jump to a specific time. var videos = new Vidyard.players(); videos["<UUID>"].on("ready",function (){ videos["DsjTGJVPhoGb4qHem7qELf"].play(); }); videos["<UUID>"].on("play",function () { videos["<UUID>"].seek(playerTime); playerTime = null; }); } } window.onload = timeCheck(); </script>
When you provide a link to the page that this code is embedded on, you will need to add a query string to the end of the URL which looks like:
?vytime=<second>
An example of this code in action can be found here:
http://www.vyexample.com/time.html?vytime=56
You are welcome to modify this code to fit your particular requirements.
Note: This functionality is already available on the sharing pages by default, but you would replace the string 'vytime' with 'second'.