Last active
August 29, 2015 14:26
-
-
Save ckahle33/ab017c0220c17110b3de to your computer and use it in GitHub Desktop.
This file contains 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
// 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