Overhead of Using EventListener vs Polling
So I have streaming video coming in, and I want to know when it is buffering. This is fundamentally not that hard, just adding an EventListener for some type of buffering event, but I was wondering if this is necessarily the "best" way to do it.
My other thought was setting up a timer that polls the video feed every X milliseconds asking it if the video isBuffering(), or somesuch. While I could, in the worst case, wait the full X milliseconds before querying the video stream, I've decided that this doesn't actually matter to me; I can work around it, and indeed do so quite naturally already.
So I'm asking: is there substantial overhead involved in having an EventListener (assuming I already have quite a few), or is the advantage of catching the buffering event right away sufficie开发者_开发知识库ntly appealing?
Leave it to the eventListener.
Although, You can avoid buffering if you dynamically change the video on the fly to a lower quality video.
精彩评论