Fade graph no longer lagging
This commit is contained in:
parent
0361d25c7b
commit
4ec1c0e09c
@ -289,11 +289,19 @@ class _Music:
|
|||||||
|
|
||||||
self._adjust_by_ms(ms)
|
self._adjust_by_ms(ms)
|
||||||
|
|
||||||
def play(self, path: str, position: Optional[float]) -> None:
|
def play(
|
||||||
|
self,
|
||||||
|
path: str,
|
||||||
|
start_time: dt.datetime,
|
||||||
|
position: Optional[float] = None,
|
||||||
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Start playing the track at path.
|
Start playing the track at path.
|
||||||
|
|
||||||
Log and return if path not found.
|
Log and return if path not found.
|
||||||
|
|
||||||
|
start_time ensures our version and our caller's version of
|
||||||
|
the start time is the same
|
||||||
"""
|
"""
|
||||||
|
|
||||||
log.info(f"Music[{self.name}].play({path=}, {position=}")
|
log.info(f"Music[{self.name}].play({path=}, {position=}")
|
||||||
@ -310,7 +318,7 @@ class _Music:
|
|||||||
|
|
||||||
if position:
|
if position:
|
||||||
self.player.set_position(position)
|
self.player.set_position(position)
|
||||||
self.start_dt = dt.datetime.now()
|
self.start_dt = start_time
|
||||||
|
|
||||||
# For as-yet unknown reasons. sometimes the volume gets
|
# For as-yet unknown reasons. sometimes the volume gets
|
||||||
# reset to zero within 200mS or so of starting play. This
|
# reset to zero within 200mS or so of starting play. This
|
||||||
@ -457,10 +465,11 @@ class _TrackManager:
|
|||||||
def play(self, position: Optional[float] = None) -> None:
|
def play(self, position: Optional[float] = None) -> None:
|
||||||
"""Play track"""
|
"""Play track"""
|
||||||
|
|
||||||
self.player.play(self.path, position)
|
|
||||||
|
|
||||||
now = dt.datetime.now()
|
now = dt.datetime.now()
|
||||||
self.start_time = now
|
self.start_time = now
|
||||||
|
|
||||||
|
self.player.play(self.path, start_time=now, position=position)
|
||||||
|
|
||||||
self.end_time = self.start_time + dt.timedelta(milliseconds=self.duration)
|
self.end_time = self.start_time + dt.timedelta(milliseconds=self.duration)
|
||||||
|
|
||||||
# Calculate time fade_graph should start updating
|
# Calculate time fade_graph should start updating
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user