From a5d5a454051d852e399f39fcd95b16b2437b3d6e Mon Sep 17 00:00:00 2001 From: marcsello Date: Sat, 12 Jun 2021 21:57:16 +0200 Subject: [PATCH] Fixed simpleaudio exceptions --- birbnetes_iot_platform_raspberry/playback_stuff.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/birbnetes_iot_platform_raspberry/playback_stuff.py b/birbnetes_iot_platform_raspberry/playback_stuff.py index 44cdd25..d2da755 100644 --- a/birbnetes_iot_platform_raspberry/playback_stuff.py +++ b/birbnetes_iot_platform_raspberry/playback_stuff.py @@ -2,7 +2,7 @@ import simpleaudio import random import os import os.path - +import logging class ShuffledFolderPlayer: @@ -14,7 +14,12 @@ class ShuffledFolderPlayer: ) def play_one_random(self): - random.choice(self._sounds).play() + # noinspection PyBroadException + try: + random.choice(self._sounds).play() + except Exception as e: # simpleaudio seems like it does not expose the exceptions it may raise. So we just log it and call it a day + logging.warning(f"Could not play sound file! {e}") + pass class BirbnetesIoTPlatformPlaybackDriver: