Skip to content

Commit f3bd96c

Browse files
Improved loop selection.
1 parent 4ab5742 commit f3bd96c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

ui/sura_player_ui/audio_looper.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ def __init__(self, player: SurahPlayer, loop_check_interval: int = 100):
1919
:param loop_check_interval: Interval (in milliseconds) to check the player's position.
2020
"""
2121
self.player = player
22-
self.loop_start = None # Start point (A)
23-
self.loop_end = None # End point (B)
22+
self.loop_start = 0 # Start point (A)
23+
self.loop_end = 0 # End point (B)
2424
self.loop_active = False # Loop state
2525
self.loop_delay = 100 # Delay (in milliseconds) before restarting the loop
2626

@@ -32,11 +32,15 @@ def __init__(self, player: SurahPlayer, loop_check_interval: int = 100):
3232
def set_loop_start(self):
3333
"""Set the start point (A) for the repeat loop."""
3434
self.loop_start = self.player.get_position()
35+
if self.loop_start > self.loop_end:
36+
self.loop_end = self.player.get_length()
3537
UniversalSpeech.say(f"Start point set at {self.loop_start} seconds.")
3638

3739
def set_loop_end(self):
3840
"""Set the end point (B) for the repeat loop."""
3941
self.loop_end = self.player.get_position()
42+
if self.loop_end < self.loop_start:
43+
self.loop_start = 0
4044
UniversalSpeech.say(f"End point set at {self.loop_end} seconds.")
4145

4246
def toggle_loop(self):
@@ -95,8 +99,8 @@ def resume(self):
9599

96100
def clear_loop(self):
97101
"""Clear the loop points and stop the loop."""
98-
self.loop_start = None
99-
self.loop_end = None
102+
self.loop_start = 0
103+
self.loop_end = 0
100104
self.loop_active = False
101105
if self.monitor_timer.isActive():
102106
self.monitor_timer.stop()

0 commit comments

Comments
 (0)