aboutsummaryrefslogtreecommitdiff
path: root/helpers/action.py
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2016-07-14 23:44:25 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2016-07-14 23:44:25 +0200
commit6f4944c18398a7482297bd1d80fcd4ee926270ae (patch)
tree1980c46c32fee0d1544656bbaa8bd5a159893b6d /helpers/action.py
parent52d58baf7a39e5e09a0b4ce24b1e951d98e7618b (diff)
downloadMusicSampler-6f4944c18398a7482297bd1d80fcd4ee926270ae.tar.gz
MusicSampler-6f4944c18398a7482297bd1d80fcd4ee926270ae.tar.zst
MusicSampler-6f4944c18398a7482297bd1d80fcd4ee926270ae.zip
Add loop option for play
Diffstat (limited to 'helpers/action.py')
-rw-r--r--helpers/action.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/helpers/action.py b/helpers/action.py
index 3dc1b8d..792b123 100644
--- a/helpers/action.py
+++ b/helpers/action.py
@@ -64,15 +64,17 @@ class Action:
64 music.unpause() 64 music.unpause()
65 65
66 def play(self, music = None, fade_in = 0, start_at = 0, 66 def play(self, music = None, fade_in = 0, start_at = 0,
67 restart_if_running = False, volume = 100, **kwargs): 67 restart_if_running = False, volume = 100,
68 loop = 0,
69 **kwargs):
68 if music is not None: 70 if music is not None:
69 if restart_if_running: 71 if restart_if_running:
70 if music.is_not_stopped(): 72 if music.is_not_stopped():
71 music.stop() 73 music.stop()
72 music.play(volume = volume, fade_in = fade_in, start_at = start_at) 74 music.play(volume = volume, fade_in = fade_in, start_at = start_at, loop = loop)
73 else: 75 else:
74 if not music.is_not_stopped(): 76 if not music.is_not_stopped():
75 music.play(volume = volume, fade_in = fade_in, start_at = start_at) 77 music.play(volume = volume, fade_in = fade_in, start_at = start_at, loop = loop)
76 78
77 def seek(self, music = None, value = 0, delta = False, **kwargs): 79 def seek(self, music = None, value = 0, delta = False, **kwargs):
78 for music in self.music_list(music): 80 for music in self.music_list(music):
@@ -124,7 +126,7 @@ class Action:
124 return "unpausing all musics" 126 return "unpausing all musics"
125 127
126 def play_print(self, music = None, fade_in = 0, start_at = 0, 128 def play_print(self, music = None, fade_in = 0, start_at = 0,
127 restart_if_running = False, volume = 100, **kwargs): 129 restart_if_running = False, volume = 100, loop = 0, **kwargs):
128 message = "starting " 130 message = "starting "
129 if music is not None: 131 if music is not None:
130 message += "« {} »".format(music.name) 132 message += "« {} »".format(music.name)
@@ -139,6 +141,11 @@ class Action:
139 141
140 message += " at volume {}%".format(volume) 142 message += " at volume {}%".format(volume)
141 143
144 if loop > 0:
145 message += " {} times".format(loop + 1)
146 elif loop < 0:
147 message += " in loop"
148
142 if restart_if_running: 149 if restart_if_running:
143 message += " (restarting if already running)" 150 message += " (restarting if already running)"
144 151