I want to listen to any play
event: https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/play_event
From the docs the listener must be attached to a video.
And the following didn’t work:
document.addEventListener("play", (event) => {
// do something when some video starts playing
});
Because I want to do some generic actions when any video starts playing in the page, so I don’t want to attach listener to every video (so to use delegation)
The reason I need to do it is because I have custom controls, and I want to be able to change the buttons (toggle play/pause for example) whenever a video is played/paused, without having the listener on the video itself every time