@@ -273,27 +273,18 @@ namespace audio_tools {
273
273
// / Setup Wifi URL
274
274
virtual void begin () {
275
275
LOGD (LOG_METHOD);
276
- setPos (-1 );
277
- }
278
-
279
- // / Defines the actual position
280
- void setPos (int newPos) {
281
- pos = newPos;
282
- if (pos >= max || pos < 0 ) {
283
- pos = -1 ;
284
- }
285
276
}
286
277
287
278
// / Opens the next url from the array
288
279
Stream* nextStream (int offset) {
289
280
pos += offset;
290
- if (pos < 0 || pos >= max) {
291
- pos = 0 ;
281
+ if (pos < 1 || pos > max) {
282
+ pos = 1 ;
292
283
}
293
- LOGI (" nextStream: %d -> %s" , pos, urlArray[pos]);
284
+ LOGI (" nextStream: %d -> %s" , String ( pos) + " / " + String (max) , urlArray[pos- 1 ]);
294
285
if (offset != 0 || actual_stream == nullptr ) {
295
286
if (started) actual_stream->end ();
296
- actual_stream->begin (urlArray[pos], mime);
287
+ actual_stream->begin (urlArray[pos- 1 ], mime);
297
288
started = true ;
298
289
}
299
290
return actual_stream;
@@ -303,18 +294,18 @@ namespace audio_tools {
303
294
Stream* selectStream (int Station) {
304
295
// pos += offset;
305
296
pos = Station;
306
- if (pos < 0 ) {
307
- pos = 0 ;
308
- LOGI (" array out of limits: %d -> %s " , Station, pos);
297
+ if (pos < 1 ) {
298
+ pos = 1 ;
299
+ LOGI (" url array out of limits: %d -> %d " , Station, pos);
309
300
}
310
- if (pos >= max) {
311
- pos = max- 1 ;
312
- LOGI (" array out of limits: %d -> %s " , Station, pos);
301
+ if (pos > max) {
302
+ pos = max;
303
+ LOGI (" url array out of limits: %d -> %d " , Station, pos);
313
304
}
314
- LOGI (" selectStream: %d -> %s" , pos, urlArray[pos]);
305
+ LOGI (" selectStream: %s -> %s" , String ( pos) + " / " + String (max) , urlArray[pos- 1 ]);
315
306
if (Station != 0 || actual_stream == nullptr ) {
316
307
if (started) actual_stream->end ();
317
- actual_stream->begin (urlArray[pos], mime);
308
+ actual_stream->begin (urlArray[pos- 1 ], mime);
318
309
started = true ;
319
310
}
320
311
return actual_stream;
@@ -323,13 +314,13 @@ namespace audio_tools {
323
314
// / Opens the Previous url from the array
324
315
Stream* previousStream (int offset) {
325
316
pos -= offset;
326
- if (pos < 0 || pos >= max) {
327
- pos = max - 1 ;
317
+ if (pos < 1 || pos > max) {
318
+ pos = max;
328
319
}
329
- LOGI (" previousStream: %d -> %s" , pos, urlArray[pos]);
320
+ LOGI (" previousStream: %s -> %s" , String ( pos) + " / " + String (max) , urlArray[pos- 1 ]);
330
321
if (offset != 0 || actual_stream == nullptr ) {
331
322
if (started) actual_stream->end ();
332
- actual_stream->begin (urlArray[pos], mime);
323
+ actual_stream->begin (urlArray[pos- 1 ], mime);
333
324
started = true ;
334
325
}
335
326
return actual_stream;
@@ -477,7 +468,7 @@ namespace audio_tools {
477
468
virtual bool begin (bool isActive = true ) {
478
469
LOGD (LOG_METHOD);
479
470
bool result = false ;
480
-
471
+
481
472
// start dependent objects
482
473
p_out_decoding->begin ();
483
474
p_source->begin ();
0 commit comments