X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=helpers%2Faction.py;h=b921fbff18c8a263d9473b748c0602a36aed6445;hb=60979de4e9f5f3f249f4887b8fecfe94f233b3d4;hp=d4c6252db70df932f954cc94e0ef26db75322b55;hpb=9d505ec9accd9a84bc6f22f4118bed9669c32fc8;p=perso%2FImmae%2FProjets%2FPython%2FMusicSampler.git diff --git a/helpers/action.py b/helpers/action.py index d4c6252..b921fbf 100644 --- a/helpers/action.py +++ b/helpers/action.py @@ -24,14 +24,13 @@ class Action: def ready(self): if 'music' in self.arguments: - return self.arguments['music'].loaded + return self.arguments['music'].check_is_loaded() else: return True def run(self): print(self.description()) getattr(self, self.action)(**self.arguments) - pygame.event.post(pygame.event.Event(pygame.USEREVENT)) def description(self): return getattr(self, self.action + "_print")(**self.arguments) @@ -43,13 +42,17 @@ class Action: if music is not None: music.pause() else: - pygame.mixer.pause() + for music in self.key.parent.open_files.values(): + if music.is_playing() and not music.is_paused(): + music.pause() def unpause(self, music = None, **kwargs): if music is not None: music.unpause() else: - pygame.mixer.unpause() + for music in self.key.parent.open_files.values(): + if music.is_playing() and music.is_paused(): + music.unpause() def play(self, music = None, fade_in = 0, start_at = 0, restart_if_running = False, volume = 100, **kwargs): @@ -74,7 +77,7 @@ class Action: pygame.mixer.stop() def stop_all_actions(self, **kwargs): - self.key.mapping.stop_all_running() + self.key.parent.stop_all_running() def volume(self, music = None, value = 100, **kwargs): if music is not None: