aboutsummaryrefslogtreecommitdiff
path: root/helpers/actions/stop.py
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2016-07-26 16:35:05 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2016-07-26 16:35:05 +0200
commite4917bcc6c5355a82f05880a389d0a1fd868561d (patch)
tree56f030600ad200632d0e9030c3b470dcb846215d /helpers/actions/stop.py
parentdb905e0706ab9a1f92102e86f677c66371be4621 (diff)
parentc4f4f2a1d330d8e09021619bbb8dcaac4df0a602 (diff)
downloadMusicSampler-e4917bcc6c5355a82f05880a389d0a1fd868561d.tar.gz
MusicSampler-e4917bcc6c5355a82f05880a389d0a1fd868561d.tar.zst
MusicSampler-e4917bcc6c5355a82f05880a389d0a1fd868561d.zip
Merge branch 'actions_cleanup'
Diffstat (limited to 'helpers/actions/stop.py')
-rw-r--r--helpers/actions/stop.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/helpers/actions/stop.py b/helpers/actions/stop.py
new file mode 100644
index 0000000..88cc66d
--- /dev/null
+++ b/helpers/actions/stop.py
@@ -0,0 +1,42 @@
1def run(action, music=None, fade_out=0, wait=False,
2 set_wait_id=None, **kwargs):
3 previous = None
4 for music in action.music_list(music):
5 if music.is_loaded_paused() or music.is_loaded_playing():
6 if previous is not None:
7 previous.stop(fade_out=fade_out)
8 previous = music
9 else:
10 music.stop(fade_out=fade_out)
11
12 if previous is not None:
13 action.waiting_music = previous
14 previous.stop(
15 fade_out=fade_out,
16 wait=wait,
17 set_wait_id=set_wait_id)
18
19def description(action, music=None, fade_out=0, wait=False,
20 set_wait_id=None, **kwargs):
21
22 message = "stopping "
23 if music is not None:
24 message += "music « {} »".format(music.name)
25 else:
26 message += "all musics"
27
28 if fade_out > 0:
29 message += " with {}s fadeout".format(fade_out)
30 if wait:
31 if set_wait_id is not None:
32 message += " (waiting the end of fadeout, with id {})"\
33 .format(set_wait_id)
34 else:
35 message += " (waiting the end of fadeout)"
36
37 return message
38
39def interrupt(action, music=None, fade_out=0, wait=False,
40 set_wait_id=None, **kwargs):
41 if action.waiting_music is not None:
42 action.waiting_music.wait_event.set()