Radio Player does not reconnect in case of wifi loss
Hi,
i used your example in Readme.md as a simple radio player.
If WiFi drops because of weak connection i get the following info:
```
14:04:38.108 -> stream title: Bonobo - Terrapin (Sonorous Mix)
14:05:34.992 -> info: ....... slow stream, dropouts are possible
14:05:35.994 -> info: ....... slow stream, dropouts are possible
14:05:36.995 -> info: ....... slow stream, dropouts are possible
14:05:37.998 -> info: ....... slow stream, dropouts are possible
14:05:38.614 -> info: ....... Stream lost -> try new connection
14:05:38.614 -> info: ....... next URL: "http://player.streamhosting.ch/lounge128.mp3"
14:05:38.614 -> info: ....... The host has disconnected, reconnecting
14:05:45.575 -> info: ....... MP3Decoder has been destroyed
end
```
Maybe it tries once, but nothing happens, because the WiFi connection is broken and needs to be reconnected when it is available again.
This is my workaround:
```
in my_audio_info:
case Audio::evt_info: { Serial.printf("info: ....... %s\n", m.msg);
if (strstr(m.msg, "Stream lost")) {
connected = false;
} break;
}
```
```
in Loop():
if (!connected) {
if (WiFi.status() != WL_CONNECTED) WiFi.begin(ssid, password);
int i = 0;
while ((WiFi.status() != WL_CONNECTED) && (i++ < 25)) delay(200);
if (audio.connecttohost(stations[Station-1])) {
connected = true;
} else {
Serial.println("No connection to host");
connected = false;
}
}
```
2 条评论