changeset 2430:1082f0725c32

fix PlayerState semantics
author drewp@bigasterisk.com
date Tue, 28 May 2024 15:34:03 -0700
parents 7888cfff657b
children d1946cb32121
files src/light9/ascoltami/player.py
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/light9/ascoltami/player.py	Tue May 28 15:33:24 2024 -0700
+++ b/src/light9/ascoltami/player.py	Tue May 28 15:34:03 2024 -0700
@@ -65,13 +65,15 @@
                     log.info("autostop")
                     self.pause()
 
+                eos = t >= self.duration() - .1  #todo
+                playing = self.isPlaying() and not eos
                 ps = PlayerState(
                     song=self._getSongFileUri(),
                     duration=round(self.duration(), 2),
-                    wallStartTime=round(now - t, 2) if self.isPlaying() else None,
-                    playing=self.isPlaying(),
-                    pausedSongTime=None if self.isPlaying() else t,
-                    endOfSong=t >= self.duration() - .1,  #todo
+                    wallStartTime=round(now - t, 2) if playing else None,
+                    playing=playing,
+                    pausedSongTime=None if playing else t,
+                    endOfSong=eos,
                 )
 
                 if self.playerState != ps: