I add event listeners - as in this example https://gist.github.com/Offbeatmammal/3718414 - for what I want to track. You can either point all the events to a single function (which I did for that example) of attach specific ones depending on your logic
Capturing and handling HTML5 video events
-
04-06-2022 - |
Question
I'm trying to develop custom HTML5 video player. Struggling a little bit with getting my head round as to how should I handle events that I'm capturing. For example:
//this will work
video.oncanplay = alert("can play");
//this won't work
video.oncanplay = function(){
alert("can play");
}
//but this will work
video.oncanplay = (function(){
alert("can play");
})();
Is a self invoking function a right approach? Or should I try something else? Tried to read w3c documentation but failed to grasp it.
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow