Adding the next track/previous track function

While we had defined the code for fast forward and rewind in the Player class, we did not define the method related to next track and previous track there, because this can be handled by the existing play method. All that you need to do is simply increment or decrement the value of current_track and then call the play method. Accordingly, define two methods in the View class, as follows (see code 5.04view.py):

def play_previous_track(self):
self.current_track_index = max(0, self.current_track_index - 1)
self.start_play()

def play_next_track(self):
self.current_track_index = min(self.list_box.size() - 1,
self.current_track_index + 1)
self.start_play()

Then, simply attach these two methods to the respective command callback, as follows (see code 5.04view.py):

def on_previous_track_button_clicked(self):
self.play_previous_track()

def on_next_track_button_clicked(self):
self.play_next_track()
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.22.160