]> git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/blobdiff - helpers/action.py
Use workflow for music_files
[perso/Immae/Projets/Python/MusicSampler.git] / helpers / action.py
index 1cb168650c765301039a48132f34eb2684119c26..b921fbff18c8a263d9473b748c0602a36aed6445 100644 (file)
@@ -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):
@@ -69,12 +72,12 @@ class Action:
             music.stop(fade_out = fade_out)
         else:
             if fade_out > 0:
-                pygame.fadeout(fade_out * 1000)
+                pygame.mixer.fadeout(int(fade_out * 1000))
             else:
                 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: