diff --git a/bt-audioparser/bt-audioparser.py b/bt-audioparser/bt-audioparser.py index d2c0045..60872d7 100644 --- a/bt-audioparser/bt-audioparser.py +++ b/bt-audioparser/bt-audioparser.py @@ -50,17 +50,19 @@ def on_property_changed(interface, changed, invalidated): def on_mqtt_ctrl(client, userdata, message): - if message.topic == config.MQTT_TOPIC + "/PLAY": - player_iface.Play() - elif message.topic == config.MQTT_TOPIC + "/PAUSE": - player_iface.Pause() - elif message.topic == config.MQTT_TOPIC + "/TRACK_PREV": - player_iface.Previous() - elif message.topic == config.MQTT_TOPIC + "/TRACK_NEXT": - player_iface.Next() - else: - logger.info(message.topic) - + try: + if message.topic == config.MQTT_TOPIC + "/PLAY": + player_iface.Play() + elif message.topic == config.MQTT_TOPIC + "/PAUSE": + player_iface.Pause() + elif message.topic == config.MQTT_TOPIC + "/TRACK_PREV": + player_iface.Previous() + elif message.topic == config.MQTT_TOPIC + "/TRACK_NEXT": + player_iface.Next() + else: + logger.info(message.topic) + except AttributeError: + logger.warning("Player control impossible due to no player available.") if __name__ == "__main__": report.stdoutLoggingConfigure(((config.APP_NAME, config.LOGLVL), ), fmt=config.formatter)