@@ -39,15 +39,17 @@ namespace audio_tools {
39
39
// / Returns next audio stream
40
40
virtual Stream* nextStream (int offset) = 0;
41
41
42
+ // / Returns previous audio stream
43
+ virtual Stream* previousStream (int offset) {
44
+ return nextStream (-offset);
45
+ };
46
+
42
47
// / Returns next audio stream
43
48
virtual Stream* selectStream (int index) {
44
49
LOGE (" Not Supported!" );
45
50
return nullptr ;
46
51
}
47
52
48
- // / Returns previous audio stream
49
- virtual Stream* previousStream (int offset) = 0;
50
-
51
53
// / Provides the timeout which is triggering to move to the next stream
52
54
virtual int timeoutMs () {
53
55
return 500 ;
@@ -156,6 +158,9 @@ namespace audio_tools {
156
158
LOGD (LOG_METHOD);
157
159
// move to next file
158
160
pos += offset;
161
+ if (pos<0 ){
162
+ pos = 0 ;
163
+ }
159
164
file.close ();
160
165
file = getFile (start_path, pos);
161
166
file.getName (file_name, MAX_FILE_LEN);
@@ -167,7 +172,7 @@ namespace audio_tools {
167
172
file.close ();
168
173
file = getFile (start_path, index);
169
174
file.getName (file_name, MAX_FILE_LEN);
170
- LOGI (" -> nextStream : '%s'" , file_name);
175
+ LOGI (" -> selectStream : '%s'" , file_name);
171
176
return file ? &file : nullptr ;
172
177
}
173
178
@@ -281,7 +286,7 @@ namespace audio_tools {
281
286
if (pos < 1 || pos > max) {
282
287
pos = 1 ;
283
288
}
284
- LOGI (" nextStream: %d -> %s" , String ( pos) + " / " + String ( max) , urlArray[pos-1 ]);
289
+ LOGI (" nextStream: %d/%d -> %s" , pos, max, urlArray[pos-1 ]);
285
290
if (offset != 0 || actual_stream == nullptr ) {
286
291
if (started) actual_stream->end ();
287
292
actual_stream->begin (urlArray[pos-1 ], mime);
@@ -302,7 +307,7 @@ namespace audio_tools {
302
307
pos = max;
303
308
LOGI (" url array out of limits: %d -> %d" , Station, pos);
304
309
}
305
- LOGI (" selectStream: %s -> %s" , String ( pos) + " / " + String ( max) , urlArray[pos-1 ]);
310
+ LOGI (" selectStream: %d/%d -> %s" , pos, max, urlArray[pos-1 ]);
306
311
if (Station != 0 || actual_stream == nullptr ) {
307
312
if (started) actual_stream->end ();
308
313
actual_stream->begin (urlArray[pos-1 ], mime);
@@ -317,7 +322,7 @@ namespace audio_tools {
317
322
if (pos < 1 || pos > max) {
318
323
pos = max;
319
324
}
320
- LOGI (" previousStream: %s -> %s" , String ( pos) + " / " + String ( max) , urlArray[pos-1 ]);
325
+ LOGI (" previousStream: %d/%d -> %s" , pos, max, urlArray[pos-1 ]);
321
326
if (offset != 0 || actual_stream == nullptr ) {
322
327
if (started) actual_stream->end ();
323
328
actual_stream->begin (urlArray[pos-1 ], mime);
0 commit comments