I'm trying to track the event of an HTML5 Video, specifically the pause/play on the default control bar (for non-mobile Chrome and Safari).
Here's my test code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Video Test</title>
</head>
<body>
<video id="video" width="320" height="240" src="http://www.w3schools.com/tags/mov_bbb.mp4" controls>
<source src="http://www.w3schools.com/tags/mov_bbb.mp4" type="video/mp4">
</video>
<script>
var video = document.getElementById("video");
video.onclick = function(){
if(!this.paused) {
this.pause();
console.log("paused");
} else {
this.play();
console.log("playing");
}
}
</script>
</body>
</html>
If I toggle play/pause in the center of the video, the event fires just fine.
The problem is that when I click the Pause/Play button on the default control bar (lower left), although the video pauses/plays, the log does not display (I assume the event does fire since it pauses/plays).
I've not found a reason for the log to not display and was hoping someone to point me in the right direction.
In my actual code, depending on whether the video is paused or played, a timer function will be called (or killed).
Thanks.
Stephen