I am trying to pause a video object at a moment. I am baffled at the complex comparison I need to do in order to accomplish this. Maybe it is necessary, but it seems like it should be simpler.
The following does not work:
video.addEventListener("timeupdate", function() {
if (this.currentTime == video.endTime) {
this.pause();
}
}, false);
The following does work:
video.addEventListener("timeupdate", function() {
if (this.currentTime >= video.endTime && this.currentTime < (video.endTime + 1)) {
this.pause();
}
}, false);
How can that be? According to HTML Audio/Video DOM currentTime Property, this value is in seconds. I can only imagine that these seconds are not necessarily whole numbers. If that were the case than I can see a possibility for my listener not to check at the instant the number is whole. This just seems like a silly bit of cruft.
How can I compare for when the two times are equal?