Skip to content

Commit 7bbf2b9

Browse files
committed
Command #32 solved.
1 parent 8a3a7ef commit 7bbf2b9

File tree

1 file changed

+17
-26
lines changed

1 file changed

+17
-26
lines changed

src/AudioTools/AudioPlayer.h

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -273,27 +273,18 @@ namespace audio_tools {
273273
/// Setup Wifi URL
274274
virtual void begin() {
275275
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-
}
285276
}
286277

287278
/// Opens the next url from the array
288279
Stream* nextStream(int offset) {
289280
pos += offset;
290-
if (pos < 0 || pos >= max) {
291-
pos = 0;
281+
if (pos < 1 || pos > max) {
282+
pos = 1;
292283
}
293-
LOGI("nextStream: %d -> %s", pos, urlArray[pos]);
284+
LOGI("nextStream: %d -> %s", String(pos) + "/" + String(max), urlArray[pos-1]);
294285
if (offset != 0 || actual_stream == nullptr) {
295286
if (started) actual_stream->end();
296-
actual_stream->begin(urlArray[pos], mime);
287+
actual_stream->begin(urlArray[pos-1], mime);
297288
started = true;
298289
}
299290
return actual_stream;
@@ -303,18 +294,18 @@ namespace audio_tools {
303294
Stream* selectStream(int Station) {
304295
//pos += offset;
305296
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);
309300
}
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);
313304
}
314-
LOGI("selectStream: %d -> %s", pos, urlArray[pos]);
305+
LOGI("selectStream: %s -> %s", String(pos) + "/" + String(max), urlArray[pos-1]);
315306
if (Station != 0 || actual_stream == nullptr) {
316307
if (started) actual_stream->end();
317-
actual_stream->begin(urlArray[pos], mime);
308+
actual_stream->begin(urlArray[pos-1], mime);
318309
started = true;
319310
}
320311
return actual_stream;
@@ -323,13 +314,13 @@ namespace audio_tools {
323314
/// Opens the Previous url from the array
324315
Stream* previousStream(int offset) {
325316
pos -= offset;
326-
if (pos < 0 || pos >= max) {
327-
pos = max - 1;
317+
if (pos < 1 || pos > max) {
318+
pos = max;
328319
}
329-
LOGI("previousStream: %d -> %s", pos, urlArray[pos]);
320+
LOGI("previousStream: %s -> %s", String(pos) + "/" + String(max), urlArray[pos-1]);
330321
if (offset != 0 || actual_stream == nullptr) {
331322
if (started) actual_stream->end();
332-
actual_stream->begin(urlArray[pos], mime);
323+
actual_stream->begin(urlArray[pos-1], mime);
333324
started = true;
334325
}
335326
return actual_stream;
@@ -477,7 +468,7 @@ namespace audio_tools {
477468
virtual bool begin(bool isActive = true) {
478469
LOGD(LOG_METHOD);
479470
bool result = false;
480-
471+
481472
// start dependent objects
482473
p_out_decoding->begin();
483474
p_source->begin();

0 commit comments

Comments
 (0)