27 LOGE(
"Not Supported!");
41 timeout_auto_next_value = millisec;
46 return timeout_auto_next_value;
62 int timeout_auto_next_value = 500;
78 this->onStartCallback = onStartCallback;
79 this->nextStreamCallback = nextStreamCallback;
85 if (onStartCallback !=
nullptr) onStartCallback();
91 return nextStreamCallback ==
nullptr ? nullptr : nextStreamCallback(offset);
96 LOGI(
"selectStream: %d", index);
97 if (indexStreamCallback==
nullptr){
98 LOGI(
"setCallbackSelectStream not provided");
107 return indexStreamCallback(index);
112 return indexStreamCallback ==
nullptr ? nullptr : indexStreamCallback(-1);
115 void setCallbackOnStart(
void (*callback)()) {
116 onStartCallback = callback;
119 void setCallbackNextStream(Stream* (*callback)(
int offset)) {
120 nextStreamCallback = callback;
123 void setCallbackSelectStream(Stream* (*callback)(
int idx)) {
124 indexStreamCallback = callback;
131 virtual void setAutoNext(
bool a){
136 virtual const char* getPath() {
141 void (*onStartCallback)() =
nullptr;
142 bool auto_next =
true;
143 Stream* (*nextStreamCallback)(
int offset) =
nullptr;
144 Stream* (*indexStreamCallback)(
int index) =
nullptr;
145 const char*path=
nullptr;
148 #if defined(USE_URL_ARDUINO) && ( defined(ESP32) || defined(ESP8266) )
158 template<
typename T,
size_t N>
161 this->actual_stream = &urlStream;
163 this->urlArray = urlArray;
165 this->pos = startPos - 1;
166 this->timeout_auto_next_value = 20000;
180 LOGI(
"url array out of limits: %d -> %d", idx, pos);
184 LOGI(
"url array out of limits: %d -> %d", idx, pos);
186 LOGI(
"selectStream: %d/%d -> %s", pos, size() - 1, value(pos));
187 if (started) actual_stream->end();
188 actual_stream->begin(value(pos), mime);
190 return actual_stream;
196 if (pos < 0 || pos >= size()) {
199 LOGI(
"nextStream: %d/%d -> %s", pos, max-1, value(pos));
206 if (pos < 0 || pos >= size()) {
209 LOGI(
"previousStream: %d/%d -> %s", pos, size() - 1, value(pos));
215 LOGI(
"selectStream: %s", path);
216 if (started) actual_stream->end();
217 actual_stream->begin(path, mime);
219 return actual_stream;
226 const char *toStr() {
232 actual_stream->setTimeout(millisec);
243 return actual_stream->setMetadataCallback(fn);
248 AbstractURLStream* actual_stream =
nullptr;
249 const char** urlArray;
252 const char* mime =
nullptr;
253 bool started =
false;
258 virtual const char* value(
int pos){
259 return urlArray[pos];
278 template<
typename T,
size_t N>
280 this->actual_stream = &urlStream;
282 this->pos = startPos - 1;
283 this->timeout_auto_next_value = 20000;
284 for (
int j=0;j<N;j++){
290 this->actual_stream = &urlStream;
292 this->pos = startPos - 1;
293 this->timeout_auto_next_value = 20000;
298 url_vector.push_back(url);
306 Vector<StrExt> url_vector;
308 const char* value(
int pos)
override {
309 return url_vector[pos].c_str();
312 int size()
override {
313 return url_vector.size();