I have a program whose user interface interacts with a music player class that manages a song that is playing. I use a slider as the display with methods of getPosition and setPosition which allow the slider to display the position as the song plays or set the position with the user’s interaction.
Currently it is ‘hard-wired’ but I wanted to build in some flexibility for a variety of music players.
I am learning object orientation and have reviewed the examples of observer and subject.
This situation is a back and forth depending on whether the song is playing
— the controller being the subject with the slider being the observer
or the slider is being manipulated to change the song’s position
—the slider being the subject and the music player being the observer
Is there a recommended design for this situation?
Or do you have both slider class and player class each both have observer and subject interfaces with the additional code to avoid a feedback loop?
I hope I have been somewhat clear in my description.
Thanks for observations and experience.