Skip to content

Instantly share code, notes, and snippets.

@ckahle33
Last active August 29, 2015 14:26
Show Gist options
  • Save ckahle33/ab017c0220c17110b3de to your computer and use it in GitHub Desktop.
Save ckahle33/ab017c0220c17110b3de to your computer and use it in GitHub Desktop.
// Sample HTML
//<video id="video1" controls>
// <source src="/path/to/video.webm" type="video/webm">
//</video>
// <div class="playButton"></div>
// realistically you would create custom play buttons so you can control from JS
var video = document.getElementById("video1");
var playButton = document.getElementsByClassName("playButton")[0];
video.pause() // will pause video
video.play() // will play video.
// you can wrap those methods in a event handler like a click on the play button div
playButton.addEventListener("click", function(event){
if (video.pause()) {
video.play();
} else {
video.pause();
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment