I am implenting an audio player in an app. I have two buttons – Play/pause and stop. I want to store the state of the player in a variable called status. Initially, the status is 'stopped'. If Play/pause is pressed now, then the status holds 'playing' after initiating an audio player handle for the media and playing it. If the player is already playing and 'Play/pause' is pressed, the player pauses and the status is set to 'paused'. If the player is paused and the Play/pause button is pressed, then as expected the status is set to 'playing' and the player resumes.
Therefore I need this status variable to be accessible by both the play/pause button and stop button callbacks. Additionally, I think the player handle should be global (in the sense described above) as the music shouldnt start over agin from the beginning if the Play/pause button is pressed when the music is paused. I am entirely new to object oriented programming, so kindly bear with me if I follow up your answer with an even more basic question.
Thank you for any guidance in advance.
Best Answer