One-time updates during audio playback
The audio program must update some information as soon as an audio track starts playing. Broadly speaking, there are two kinds of updates that the program needs to monitor and update:
One-time updates: Examples of this include the name of the track and the total length of the track.
Continuous updates: Examples of this include the position of the seek bar knob and the elapsed play duration. We also need to continuously check whether a track has ended to either play the next track, play the current track again, or stop playing, depending on the loop choice made by the user.
These two kinds of updates will affect sections of the audio player, as shown in the following screenshot:
Let's start with the one-time updates, as they are relatively simple to implement. Since these updates must occur when the playback starts, let's define a method named manage_one_time_updates()
and call it from within the start_play()
method of the View
class, as follows (see code...