]>
Commit | Line | Data |
---|---|---|
c4f4f2a1 IB |
1 | def 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 | ||
19 | def description(action, music=None, fade_out=0, wait=False, | |
20 | set_wait_id=None, **kwargs): | |
21 | ||
6a327173 | 22 | formats = [] |
c4f4f2a1 IB |
23 | message = "stopping " |
24 | if music is not None: | |
6a327173 IB |
25 | message += "music « {} »" |
26 | formats.append(music.name) | |
c4f4f2a1 IB |
27 | else: |
28 | message += "all musics" | |
29 | ||
30 | if fade_out > 0: | |
6a327173 IB |
31 | message += " with {}s fadeout" |
32 | formats.append(fade_out) | |
c4f4f2a1 IB |
33 | if wait: |
34 | if set_wait_id is not None: | |
6a327173 IB |
35 | message += " (waiting the end of fadeout, with id {})" |
36 | formats.append(set_wait_id) | |
c4f4f2a1 IB |
37 | else: |
38 | message += " (waiting the end of fadeout)" | |
39 | ||
6a327173 | 40 | return _(message).format(*formats) |
c4f4f2a1 IB |
41 | |
42 | def interrupt(action, music=None, fade_out=0, wait=False, | |
43 | set_wait_id=None, **kwargs): | |
44 | if action.waiting_music is not None: | |
45 | action.waiting_music.wait_event.set() |