|
@ -19,6 +19,8 @@ |
|
|
#include "esp_system.h" |
|
|
#include "esp_system.h" |
|
|
#include <math.h> |
|
|
#include <math.h> |
|
|
|
|
|
|
|
|
|
|
|
#include "HTTPClient.h" |
|
|
|
|
|
|
|
|
#include "alarmsound.h" |
|
|
#include "alarmsound.h" |
|
|
|
|
|
|
|
|
char titleStr[64]; |
|
|
char titleStr[64]; |
|
@ -118,7 +120,22 @@ void MP3::mp3_decoder_task(void *pvParameters) { |
|
|
// strcpy(titleStr, "loading...");
|
|
|
// strcpy(titleStr, "loading...");
|
|
|
if (fromProgmem) file = new AudioFileSourcePROGMEM(alarmsound, alarmsound_len); |
|
|
if (fromProgmem) file = new AudioFileSourcePROGMEM(alarmsound, alarmsound_len); |
|
|
else if (rtttl_len > 0) file = new AudioFileSourcePROGMEM( rtttl, rtttl_len ); |
|
|
else if (rtttl_len > 0) file = new AudioFileSourcePROGMEM( rtttl, rtttl_len ); |
|
|
else file = new AudioFileSourceICYStream(URL); |
|
|
else { |
|
|
|
|
|
HTTPClient http; |
|
|
|
|
|
http.begin(URL); |
|
|
|
|
|
const char* headerNames[] = { "Location", "Last-Modified" }; |
|
|
|
|
|
http.collectHeaders(headerNames, sizeof(headerNames)/sizeof(headerNames[0])); |
|
|
|
|
|
int httpCode = http.GET(); |
|
|
|
|
|
if (httpCode == HTTP_CODE_FOUND || httpCode == HTTP_CODE_SEE_OTHER) { // check for redirect
|
|
|
|
|
|
Serial.println("redirect!!!!!!!!!!!!!!!"); |
|
|
|
|
|
if (http.hasHeader("Location")) { |
|
|
|
|
|
Serial.println(http.header("Location")); |
|
|
|
|
|
http.header("Location").toCharArray(URL, 80); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
http.end(); |
|
|
|
|
|
file = new AudioFileSourceICYStream(URL); |
|
|
|
|
|
} |
|
|
file->RegisterMetadataCB(MDCallback, (void*)"ICY"); |
|
|
file->RegisterMetadataCB(MDCallback, (void*)"ICY"); |
|
|
buff = new AudioFileSourceBuffer(file, preallocateBuffer, preallocateBufferSize); |
|
|
buff = new AudioFileSourceBuffer(file, preallocateBuffer, preallocateBufferSize); |
|
|
audiobuffer = buff; |
|
|
audiobuffer = buff; |
|
|