Skip to content

Commit

Permalink
fix toggle() twice in 0.5s results pause status
Browse files Browse the repository at this point in the history
  • Loading branch information
mokurin000 committed Jan 21, 2024
1 parent 9fd312f commit 6096300
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion feeluown/player/mpvplayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ def __init__(self, _=None, audio_device=b'auto', winid=None, fade=False, **kwarg
self._mpv._event_callbacks.append(self._on_event)
logger.debug('Player initialize finished.')

# this should always be `False` for fade=False,
# because in that case `pause()` set status immediately
self.pausing = False

self.do_fade = fade
if self.do_fade:
self.fade_lock = RLock()
Expand Down Expand Up @@ -195,8 +199,10 @@ def set_volume(max_volume: int, fade_in: bool):
self._resume()
set_volume(max_volume, fade_in=True)
else:
self.pausing = True
set_volume(max_volume, fade_in=False)
self._pause()
self.pausing = False

self.volume = max_volume

Expand Down Expand Up @@ -227,7 +233,7 @@ def pause(self):
self._pause()

def toggle(self):
if self._mpv.pause:
if self.pausing or self._mpv.pause:
self.resume()
else:
self.pause()
Expand Down

0 comments on commit 6096300

Please sign in to comment.