- commit
- 22b97d2aac4b9a7a948d5e94e49bb936b36a8e2f
- parent
- d1ebb32d5fc80e96400d10844774afd6247a09a2
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2025-03-06 11:08
handle KeyboardInterrupt
Diffstat
| M | player.py | 17 | ++++++++++------- |
1 files changed, 10 insertions, 7 deletions
diff --git a/player.py b/player.py
@@ -121,13 +121,16 @@ def play(buffers, sample_rate, jumps): 121 121 n = len(buffers) 122 122 123 123 with soundcard.default_speaker().player(samplerate=sample_rate) as sp:124 -1 while True:125 -1 sp.play(buffers[i])126 -1 print_progress(i, n)127 -1128 -1 i = get_next_position(i, jumps)129 -1 if i >= n:130 -1 i = 0-1 124 try: -1 125 while True: -1 126 sp.play(buffers[i]) -1 127 print_progress(i, n) -1 128 -1 129 i = get_next_position(i, jumps) -1 130 if i >= n: -1 131 i = 0 -1 132 except KeyboardInterrupt: -1 133 print('\nStopping…') 131 134 132 135 133 136 def parse_args():