From 0c041d0bf6e484b01a2dc285d729da5209287fca Mon Sep 17 00:00:00 2001 From: Keith Edmunds Date: Sun, 11 Apr 2021 15:24:06 +0100 Subject: [PATCH] Improve detecting when track is playing. --- app/music.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/music.py b/app/music.py index e580315..f7402e2 100644 --- a/app/music.py +++ b/app/music.py @@ -86,12 +86,18 @@ class Music: self.player.play() def playing(self): - "Return True if currently playing a track, else False" + """ + Return True if currently playing a track, else False + + vlc.is_playing() returns True if track was faded out. + get_position seems more reliable. + """ if self.player: - return self.player.is_playing() - else: - return False + if self.player.get_position() > 0 and self.player.is_playing(): + return True + + return False def set_position(self, ms): "Set current play time in milliseconds from start"