@@ -59,9 +59,9 @@ namespace audio_tools {
59
59
return selectStream (index);
60
60
}
61
61
62
- // / same as selectStream - I just prefer this name
63
- virtual Stream* selectStream (char * path, char * fileName ) {
64
- return selectStream (path,fileName );
62
+ // / Returns audio stream by path
63
+ virtual Stream* selectStream (char * path) {
64
+ return selectStream (path);
65
65
}
66
66
67
67
// / Sets the timeout which is triggering to move to the next stream. - the default value is 500 ms
@@ -216,10 +216,10 @@ namespace audio_tools {
216
216
return file ? &file : nullptr ;
217
217
}
218
218
219
- virtual Stream* selectStream (char * path, char * fileName ) override {
219
+ virtual Stream* selectStream (char * path) override {
220
220
file.close ();
221
- file = getFileByPath (path, fileName );
222
- LOGW (" -> selectStream: %s%s " , path, fileName );
221
+ file = getFileByPath (path);
222
+ LOGW (" -> selectStream: %s" , path);
223
223
return file ? &file : nullptr ;
224
224
}
225
225
@@ -282,9 +282,15 @@ namespace audio_tools {
282
282
return result;
283
283
}
284
284
285
- AudioFile getFileByPath (char * path, char * fileName ) {
285
+ AudioFile getFileByPath (char * path) {
286
286
AudioFile dir;
287
- if (!dir.open (path)) {// ("/21/" , "001.mp3")
287
+ Str inPath (path);
288
+ StrExt strPath;
289
+ StrExt strfileName;
290
+ int pos = inPath.lastIndexOf (" /" ) + 1 ;
291
+ strPath.substring (path, 0 , pos);
292
+ strfileName.substring (path, pos, inPath.length ());
293
+ if (!dir.open (strPath.c_str ())) {// ("/21/" , "001.mp3")
288
294
LOGE (" directory: %s not open" , path);
289
295
}
290
296
else
@@ -294,12 +300,12 @@ namespace audio_tools {
294
300
}
295
301
else
296
302
{
297
- if (!file.open (&dir, fileName , O_RDWR)) {
303
+ if (!file.open (&dir, strfileName. c_str () , O_RDWR)) {
298
304
LOGE (" file: %s not open" , path);
299
305
}
300
306
else
301
307
{
302
- LOGD (" -> getFileByPath: '%s': %d" , path, fileName );
308
+ LOGD (" -> getFileByPath: '%s': %d" , path, strfileName. c_str () );
303
309
}
304
310
}
305
311
}
@@ -415,6 +421,15 @@ namespace audio_tools {
415
421
return selectStream (pos);
416
422
}
417
423
424
+ // / Opens the selected url
425
+ Stream* selectStream (char * path) override {
426
+ LOGI (" selectStream: %s" , path);
427
+ if (started) actual_stream->end ();
428
+ actual_stream->begin (path, mime);
429
+ started = true ;
430
+ return actual_stream;
431
+ }
432
+
418
433
int index () {
419
434
return pos;
420
435
}
@@ -647,10 +662,10 @@ namespace audio_tools {
647
662
}
648
663
649
664
// / moves to selected file
650
- virtual bool setPath (char * path, char * fileName ) {
665
+ virtual bool setPath (char * path) {
651
666
LOGD (LOG_METHOD);
652
667
previous_stream = false ;
653
- active = setStream (p_source->selectStream (path, fileName ));
668
+ active = setStream (p_source->selectStream (path));
654
669
return active;
655
670
}
656
671
0 commit comments