Adding the pause/unpause function

Since we need a single button to toggle between pause and unpause, we will again use the cycle() method from the itertools module. Define an attribute, as follows (see code 5.04view.py):

toggle_pause_unpause = itertools.cycle(["pause","unpause"])

Then, modify the command callback attached to the button, as follows:

def on_pause_unpause_button_clicked(self):
action = next(self.toggle_pause_unpause)
if action == 'pause':
self.player.pause()
elif action == 'unpause':
self.player.unpause()

This takes care of the pause and unpause features of the program.

..................Content has been hidden....................

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