play pause html5 video javascript
From what I see, video is not a function, so why do you have parentheses? That's your error.
So instead of video()
just use video
$('#play-pause-button').click(function () {
var mediaVideo = $("#media-video").get(0);
if (mediaVideo.paused) {
mediaVideo.play();
} else {
mediaVideo.pause();
}
});
I have done this in jQuery, which is simple and fast. To try it, you just need to use the ID of the video tag and your play/pause button.
EDIT: In vanilla JavaScript: a video is not a function, but part of DOM hence use
video.play();
Instead of
video().play() **wrong**