Skip to content

Instantly share code, notes, and snippets.

@nagisa
Created July 12, 2012 19:23
Show Gist options
  • Save nagisa/3100300 to your computer and use it in GitHub Desktop.
Save nagisa/3100300 to your computer and use it in GitHub Desktop.
Automatically replay HTML5 videos. Works with YT, Vimeo, etc, etc.
// Long version
document.querySelector('video').addEventListener('ended', function(e){
var target = e.currentTarget;
target.currentTime = 0;
target.play();
}
});
// Short version (snippet, bookmarklet?)
document.querySelector("video").addEventListener("ended",function(a){a=a.currentTarget;a.currentTime=0;a.play()});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment