-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathrocketmusic.py
55 lines (44 loc) · 1.28 KB
/
rocketmusic.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from demosys.timers.music import Timer as MusicTimer
from demosys.timers.rocket import Timer as RocketTimer
class Timer(RocketTimer):
"""
Combines music.Timer and rocket.Timer
"""
def __init__(self, **kwargs):
self.music = MusicTimer()
super().__init__(**kwargs)
def start(self):
"""Start the timer"""
self.music.start()
if not self.start_paused:
self.rocket.start()
def get_time(self) -> float:
"""
Get the current time in seconds
Returns:
The current time in seconds
"""
self.rocket.update()
return self.music.get_time()
def set_time(self, value: float):
"""
Set the current time jumping in the timeline
Args:
value (float): The new time value
"""
self.music.set_time(value)
def pause(self):
"""Pause the timer"""
self.controller.playing = False
self.music.pause()
def toggle_pause(self):
"""Toggle pause mode"""
self.controller.playing = not self.controller.playing
self.music.toggle_pause()
def stop(self) -> float:
"""
Stop the timer
Returns:
The current time
"""
return self.rocket.time