Skip to content

Commit 3c0c74b

Browse files
Updated PlayBackStatus in AudioPlayer.
1 parent 1c21148 commit 3c0c74b

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

utils/audio_player/bass_player.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,15 @@ def get_playback_status(self) -> PlaybackStatus:
104104
return PlaybackStatus.STOPPED
105105

106106
status = bass.BASS_ChannelIsActive(self.current_channel)
107-
if status == PlaybackStatus.PLAYING.value or status == PlaybackStatus.FIRST_PLAYING.value:
108-
return PlaybackStatus.PLAYING
109-
elif status == PlaybackStatus.PAUSED .value:
110-
return PlaybackStatus.PAUSED
111-
else:
112-
return PlaybackStatus.STOPPED
107+
match status:
108+
case PlaybackStatus.PLAYING.value:
109+
return PlaybackStatus.PLAYING
110+
case PlaybackStatus.PAUSED.value:
111+
return PlaybackStatus.PAUSED
112+
case PlaybackStatus.STALLED.value:
113+
return PlaybackStatus.STALLED
114+
case other:
115+
return PlaybackStatus.STOPPED
113116

114117
def is_playing(self) -> bool:
115118
"""Checks if the audio is currently playing."""
@@ -119,7 +122,11 @@ def is_paused(self) -> bool:
119122
"""Checks if the audio is currently paused."""
120123
return self.get_playback_status() == PlaybackStatus.PAUSED
121124

125+
def is_stalled(self) -> bool:
126+
"""Checks if the channel is activ but stalled waiting for more data"""
127+
return self.get_playback_status() == PlaybackStatus.STALLED
128+
122129
def is_stopped(self) -> bool:
123130
"""Checks if the audio is currently stopped."""
124-
return self.get_playback_status() == PlaybackStatus.STOPPED
131+
return self.get_playback_status() == PlaybackStatus.STOPPED
125132

utils/audio_player/status.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
class PlaybackStatus(Enum):
44
STOPPED = 0
55
PLAYING = 1
6-
FIRST_PLAYING = 2
6+
STALLED = 2
77
PAUSED = 3

0 commit comments

Comments
 (0)