Last active
June 14, 2016 13:22
-
-
Save FuruholmAnton/474580c6248a6e7aa4112818a7f97acf 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
/*---------- VIDEO ----------*/ | |
var video = (function() { | |
'use strict'; | |
function video(elem) { | |
// enforces new | |
if (!(this instanceof video)) { | |
return new video(elem); | |
} | |
this.player = document.querySelector(elem); | |
} | |
video.prototype.play = function() { | |
this.player.play(); | |
}; | |
video.prototype.pause = function() { | |
this.player.pause(); | |
}; | |
video.prototype.seek = function(time) { | |
this.player.currentTime = parseInt(time); | |
}; | |
return video; | |
}()); | |
var video = new video('.js-video'); | |
var button = document.querySelector(".play"); | |
button.addEventListener("click", function(){ | |
video.play(); | |
}); | |
var pause = document.querySelector(".pause"); | |
pause.addEventListener("click", function(){ | |
video.pause(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment