Add DEBUG statements to investigate issue #11
This commit is contained in:
parent
caf78df17f
commit
6310dfd5c7
23
app/music.py
23
app/music.py
@ -30,7 +30,7 @@ class Music:
|
||||
to hold up the UI during the fade.
|
||||
"""
|
||||
|
||||
DEBUG("music.fade()")
|
||||
DEBUG("music.fade()", True)
|
||||
|
||||
if not self.playing():
|
||||
return None
|
||||
@ -45,7 +45,11 @@ class Music:
|
||||
Implementation of fading the current track in a separate thread.
|
||||
"""
|
||||
|
||||
DEBUG("music._fade()")
|
||||
# Take a copy of current player to allow another track to be
|
||||
# started without interfering here
|
||||
p = self.player
|
||||
|
||||
DEBUG(f"music._fade(), {self.player=}", True)
|
||||
|
||||
fade_time = Config.FADE_TIME / 1000
|
||||
steps = Config.FADE_STEPS
|
||||
@ -58,9 +62,6 @@ class Music:
|
||||
# (n**2 + n) / 2
|
||||
total_measures_count = (steps**2 + steps) / 2
|
||||
|
||||
# Take a copy of current player to allow another track to be
|
||||
# started without interfering here
|
||||
p = self.player
|
||||
measures_to_reduce_by = 0
|
||||
for i in range(1, steps + 1):
|
||||
measures_to_reduce_by += i
|
||||
@ -69,6 +70,7 @@ class Music:
|
||||
sleep(sleep_time)
|
||||
|
||||
p.stop()
|
||||
DEBUG(f"Releasing play {p=}", True)
|
||||
p.release()
|
||||
self.fading = False
|
||||
|
||||
@ -83,7 +85,7 @@ class Music:
|
||||
def get_position(self):
|
||||
"Return current position"
|
||||
|
||||
DEBUG("music.get_position")
|
||||
DEBUG("music.get_position", True)
|
||||
|
||||
return self.player.get_position()
|
||||
|
||||
@ -94,8 +96,6 @@ class Music:
|
||||
Log and return if path not found.
|
||||
"""
|
||||
|
||||
DEBUG(f"music.play({path})")
|
||||
|
||||
if not os.access(path, os.R_OK):
|
||||
ERROR(f"play({path}): path not found")
|
||||
return
|
||||
@ -104,6 +104,7 @@ class Music:
|
||||
|
||||
self.player = self.VLC.media_player_new(path)
|
||||
self.player.audio_set_volume(self.max_volume)
|
||||
DEBUG(f"music.play({path=}), {self.player}", True)
|
||||
self.player.play()
|
||||
self.current_track_start_time = datetime.now()
|
||||
|
||||
@ -140,15 +141,17 @@ class Music:
|
||||
def stop(self):
|
||||
"Immediately stop playing"
|
||||
|
||||
DEBUG("music.stop()")
|
||||
DEBUG("music.stop()", True)
|
||||
|
||||
if not self.player:
|
||||
return None
|
||||
|
||||
position = self.player.get_position()
|
||||
self.player.stop()
|
||||
self.player.release()
|
||||
p = self.player
|
||||
# Ensure we don't reference player after release
|
||||
self.player = None
|
||||
DEBUG(f"Releasing play {p=}", True)
|
||||
p.release()
|
||||
|
||||
return position
|
||||
|
||||
Loading…
Reference in New Issue
Block a user