@@ -20,7 +20,7 @@ def __init__(self) -> None:
2020 self .volume : float = 0.5
2121 self .supported_extensions = ('.wav' , '.mp3' , '.ogg' )
2222
23- def load_audio (self , source : str ) -> None :
23+ def load_audio (self , source : str , attempts : Optional [ int ] = 3 ) -> None :
2424 """Loads an audio file or a URL for playback."""
2525
2626 # Stop and release the previous file
@@ -41,7 +41,10 @@ def load_audio(self, source: str) -> None:
4141 self .current_channel = bass .BASS_StreamCreateFile (False , source .encode ('utf-8' ), 0 , 0 , 0 )
4242
4343 if not self .current_channel :
44- raise RuntimeError ("Failed to load audio file or URL" )
44+ if attempts :
45+ print (f"Trying too load: { source } ." )
46+ return self .load_audio (source , attempts - 1 )
47+ raise RuntimeError ("Failed to load audio file or URL: {}" .format (source ))
4548
4649 self .source = source
4750 self .set_volume (self .volume )
@@ -101,7 +104,7 @@ def get_playback_status(self) -> PlaybackStatus:
101104 return PlaybackStatus .STOPPED
102105
103106 status = bass .BASS_ChannelIsActive (self .current_channel )
104- if status == PlaybackStatus .PLAYING .value :
107+ if status == PlaybackStatus .PLAYING .value or status == PlaybackStatus . FIRST_PLAYING . value :
105108 return PlaybackStatus .PLAYING
106109 elif status == PlaybackStatus .PAUSED .value :
107110 return PlaybackStatus .PAUSED
0 commit comments