Fix play sometimes stopping almost immediately

This commit is contained in:
Keith Edmunds 2023-03-10 22:34:23 +00:00
parent ee7436221e
commit 2422adea21
2 changed files with 9 additions and 1 deletions

View File

@ -67,6 +67,7 @@ class Config(object):
MINIMUM_ROW_HEIGHT = 30
MYSQL_CONNECT = os.environ.get('MYSQL_CONNECT') or "mysql+mysqldb://musicmuster:musicmuster@localhost/musicmuster_v2" # noqa E501
NOTE_TIME_FORMAT = "%H:%M:%S"
PLAY_SETTLE = 500000
ROOT = os.environ.get('ROOT') or "/home/kae/music"
IMPORT_DESTINATION = os.path.join(ROOT, "Singles")
SCROLL_TOP_MARGIN = 3

View File

@ -1613,7 +1613,14 @@ class Window(QMainWindow, Ui_MainWindow):
return
# If track is playing, update track clocks time and colours
if self.music.player and self.music.player.is_playing():
# There is a discrete time between starting playing a track and
# player.is_playing() returning True, so assume playing if less
# than Config.PLAY_SETTLE microseconds have passed since
# starting play.
if self.music.player and self.current_track.start_time and (
self.music.player.is_playing() or
(datetime.now() - self.current_track.start_time)
< timedelta(microseconds=Config.PLAY_SETTLE)):
playtime = self.music.get_playtime()
time_to_fade = (self.current_track.fade_at - playtime)
time_to_silence = (