Skip to content

Instantly share code, notes, and snippets.

Last active Oct 21, 2020
What would you like to do?
<video width="960" height="540" controls>
<source src="" type="video/mp4">
<script type="application/javascript">
function loadPlayer() {
var urlParams = new URLSearchParams(;
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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment