Categories
Mastering Development

Is it possible to know if an html5 video was played/paused via the play()/pause() javascript methods?

I’m trying to figure out if a video was played/paused via play() and pause() javascript methods.

I thought I could achieve this by observing the ‘play’ and ‘pause’ events checking if isTrusted was false. Up to no avail, this always comes true.

Is there any way for me to know if a video was played or paused due to an user interaction?

Fiddle

__

extra:
I have even tried videoElement.dispatchEvent(new MouseEvent('click')) but this doesn’t seem to trigger the play/pause events of the video

Leave a Reply

Your email address will not be published. Required fields are marked *