Display of countdown timer works
This commit is contained in:
parent
983716e009
commit
09fdd7e4dc
@ -1000,7 +1000,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
# when starting to play at track.
|
||||
|
||||
# Resolution appears to be to disable timer10 for the first ten
|
||||
# seconds of playback. Re-enabled tick_1000ms
|
||||
# seconds of playback. Re-enable in update_clocks.
|
||||
|
||||
self.timer10.stop()
|
||||
log.debug("10ms timer disabled", 0)
|
||||
@ -1478,54 +1478,32 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
if track_sequence.current:
|
||||
track_sequence.current.update_fade_graph()
|
||||
|
||||
def tick_500ms(self) -> None:
|
||||
"""
|
||||
Called every 500ms
|
||||
"""
|
||||
|
||||
self.lblTOD.setText(dt.datetime.now().strftime(Config.TOD_TIME_FORMAT))
|
||||
|
||||
def tick_100ms(self) -> None:
|
||||
"""
|
||||
Called every 100ms
|
||||
"""
|
||||
|
||||
if track_sequence.current:
|
||||
track_sequence.current.check_for_end_of_track()
|
||||
try:
|
||||
track_sequence.current.check_for_end_of_track()
|
||||
|
||||
return
|
||||
# Update intro counter if applicable and, if updated, return
|
||||
# because playing an intro takes precedence over timing a
|
||||
# preview.
|
||||
if self.music.is_playing() and track_sequence.current.intro:
|
||||
remaining_ms = track_sequence.current.intro - self.music.get_playtime()
|
||||
if remaining_ms > 0:
|
||||
self.label_intro_timer.setText(f"{remaining_ms / 1000:.1f}")
|
||||
if remaining_ms <= Config.INTRO_SECONDS_WARNING_MS:
|
||||
self.label_intro_timer.setStyleSheet(
|
||||
f"background: {Config.COLOUR_WARNING_TIMER}"
|
||||
)
|
||||
return
|
||||
else:
|
||||
self.label_intro_timer.setStyleSheet("")
|
||||
# Update intro counter if applicable and, if updated, return
|
||||
# because playing an intro takes precedence over timing a
|
||||
# preview.
|
||||
remaining_ms = track_sequence.current.time_remaining_intro()
|
||||
if remaining_ms > 0:
|
||||
self.label_intro_timer.setText(f"{remaining_ms / 1000:.1f}")
|
||||
if remaining_ms <= Config.INTRO_SECONDS_WARNING_MS:
|
||||
self.label_intro_timer.setStyleSheet(
|
||||
f"background: {Config.COLOUR_WARNING_TIMER}"
|
||||
)
|
||||
return
|
||||
else:
|
||||
self.label_intro_timer.setStyleSheet("")
|
||||
except AttributeError:
|
||||
# currnent track ended during servicing tick
|
||||
pass
|
||||
|
||||
# Ensure preview button is reset if preview finishes playing
|
||||
self.btnPreview.setChecked(self.preview_player.is_playing())
|
||||
|
||||
# Update preview timer
|
||||
if self.preview_player.is_playing():
|
||||
playtime = self.preview_player.get_playtime()
|
||||
self.label_intro_timer.setText(f"{playtime / 1000:.1f}")
|
||||
if playtime <= 0:
|
||||
self.label_intro_timer.setStyleSheet(
|
||||
f"background: {Config.COLOUR_ENDING_TIMER}"
|
||||
)
|
||||
elif playtime <= Config.INTRO_SECONDS_WARNING_MS:
|
||||
self.label_intro_timer.setStyleSheet(
|
||||
f"background: {Config.COLOUR_WARNING_TIMER}"
|
||||
)
|
||||
else:
|
||||
self.label_intro_timer.setText("0.0")
|
||||
|
||||
def tick_1000ms(self) -> None:
|
||||
"""
|
||||
@ -1537,6 +1515,13 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
|
||||
self.update_clocks()
|
||||
|
||||
def tick_500ms(self) -> None:
|
||||
"""
|
||||
Called every 500ms
|
||||
"""
|
||||
|
||||
self.lblTOD.setText(dt.datetime.now().strftime(Config.TOD_TIME_FORMAT))
|
||||
|
||||
def update_clocks(self) -> None:
|
||||
"""
|
||||
Update track clocks.
|
||||
|
||||
@ -503,6 +503,17 @@ class _TrackManager:
|
||||
|
||||
return self.player.get_playtime()
|
||||
|
||||
def time_remaining_intro(self) -> int:
|
||||
"""
|
||||
Return milliseconds of intro remaining. Return 0 if no intro time in track
|
||||
record or if intro has finished.
|
||||
"""
|
||||
|
||||
if not self.intro:
|
||||
return 0
|
||||
|
||||
return max(0, self.intro - self.time_playing())
|
||||
|
||||
def time_to_fade(self) -> int:
|
||||
"""
|
||||
Return milliseconds until fade time. Return zero if we're not playing.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user