Last active
March 18, 2025 23:01
-
-
Save jwhitehorn/050022f760e77ad207e878691752f40b to your computer and use it in GitHub Desktop.
This file contains hidden or 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> | |
</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