Skip to content

Instantly share code, notes, and snippets.

@jwhitehorn
Last active October 21, 2020 05:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jwhitehorn/050022f760e77ad207e878691752f40b to your computer and use it in GitHub Desktop.
Save jwhitehorn/050022f760e77ad207e878691752f40b to your computer and use it in GitHub Desktop.
<html>
<head>
</head>
<body>
<video width="960" height="540" controls>
<source src="" type="video/mp4">
</video>
<script type="application/javascript">
function loadPlayer() {
var urlParams = new URLSearchParams(window.location.search);
var video = document.getElementsByTagName("video")[0];
video.src = urlParams.get("src");
video.onloadeddata = function(){
var offsetStr = urlParams.get("offset");
if(offsetStr && offsetStr.indexOf(":") > 0){
var offsetParts = offsetStr.split(":");
var frame = parseInt(offsetParts[0]);
var totalFrames = parseInt(offsetParts[1]);
var percentage = frame / totalFrames;
var targetOffsetInSeconds = video.duration * percentage;
video.currentTime = parseInt(targetOffsetInSeconds);
}
}
}
setTimeout( loadPlayer, 0);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment