From 9b5c826cca19d1a6c37cab0d7de591b6b8d14a7a Mon Sep 17 00:00:00 2001 From: Gir0fa Date: Mon, 4 Aug 2025 15:36:02 -0600 Subject: [PATCH] If Statement Nesting Error The delete_file if statement was wrongly nested inside the sleep_during_playback if statement. Doug likely never encountered issues because he likely never didn't sleep (tongue twister right there) --- audio_player.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/audio_player.py b/audio_player.py index 6893ccb..836bb03 100644 --- a/audio_player.py +++ b/audio_player.py @@ -45,15 +45,15 @@ def play_audio(self, file_path, sleep_during_playback=True, delete_file=False, p # Sleep until file is done playing time.sleep(file_length) - # Delete the file - if delete_file: - # Stop pygame so file can be deleted - # Note, this can cause issues if this function is being run on multiple threads, since it quit the mixer for the other threads too - pygame.mixer.music.stop() - pygame.mixer.quit() + # Delete the file + if delete_file: + # Stop pygame so file can be deleted + # Note, this can cause issues if this function is being run on multiple threads, since it quit the mixer for the other threads too + pygame.mixer.music.stop() + pygame.mixer.quit() - try: - os.remove(file_path) - print(f"Deleted the audio file.") - except PermissionError: - print(f"Couldn't remove {file_path} because it is being used by another process.") \ No newline at end of file + try: + os.remove(file_path) + print(f"Deleted the audio file.") + except PermissionError: + print(f"Couldn't remove {file_path} because it is being used by another process.")