My answer at How to tell if a <video> element is currently playing?:
MediaElement
does not have a property that tells about if its playing or not. But you could define a custom property for it.
Object.defineProperty(HTMLMediaElement.prototype, 'playing', {
get: function(){
return !!(this.currentTime > 0 && !this.paused && !this.ended && this.readyState > 2);
}
})
Now you can use it on video
or audio
elements like this:
if(document.querySelector('video').playing){
// Do anything you want to
}