Should I use events in this case?
Posted
by
joon
on Programmers
See other posts from Programmers
or by joon
Published on 2012-08-10T10:45:14Z
Indexed on
2012/11/23
17:19 UTC
Read the original article
Hit count: 189
event-programming
I'm creating a video player, like a custom YouTube player.
All of the GUI elements (progress bar, video player, play button, ...) are different classes, but I obviously need them to communicate. When the progress bar is clicked, or the slider is moved, it needs to send a "seek(x)" command to the video player. Similarly, the video player needs to update the progressbar every frame.
Currently I'm doing this by having almost all elements have a link to each other. So when I create the progress bar, I'm telling it where the video player is.
But after a while this becomes more and more complicated, and I'm wondering if events would be a better way to do this. Or a main controller class that has all the connections. What should I do?
© Programmers or respective owner