From the comments on the docs page: Yes, I've got the same problem. It only returns false when the music has been stopped, or no music has been loaded. Maybe there should be an is_paused() method... http://www.pygame.org/docs/ref/music.html#comment_pygame_mixer_music _get_busy
So, don't switch on get_busy(), perhaps just keep a record of the button state. e.g. if not started: pygame.mixer.music.play() started = True playing = True elif playing: pygame.mixer.music.pause() playing = False else: pygame.mixer.music.unpause() playing = True Perhaps also using set_endevent() to monitor when it has finished playing, and reset started to False. Note that in your original code, the else part is unlikely to ever run. On Sun, 2017-05-07 at 18:34 +0100, toufik wrote: > played = True > > def holder(): > time.sleep(0.001) > > def play(track): > global played > pygame.mixer.init() > pygame.mixer.music.load(track) > t = wx.PyTimer(holder) > if played : > pygame.mixer.music.play() > played = False > elif pygame.mixer.music.get_busy(): > pygame.mixer.music.pause() > elif not pygame.mixer.music.get_busy(): > pygame.mixer.music.unpause() > else: > played = True > t.Start(10)
signature.asc
Description: This is a digitally signed message part