Looping over tracks
Let's add the feature that allows users to loop over tracks. We have already defined radio buttons to allow three choices, as shown in the following screenshot:
In essence, the player should provide a choice from the following three options:
No Loop: Play a track and end there
Loop Current: Play a single track repeatedly
Loop All: Looping through the entire playlist, one after another
The decision to follow one of these three options needs to be taken immediately after a particular track ends playing. The best place to judge whether a track has come to its end is from within the periodic updates loop that we created earlier.
Therefore, modify the manage_periodic_updates_during_play()
method to add the following two lines of highlighted code (see code 5.08
– view.py
):
def manage_periodic_updates_during_play(self): self.update_clock() self.update_seek_bar() if not self.player.is_playing(): if self.not_to_loop(): return self.root...