5 #include "AudioLogger.h"
6 #include "AudioBasic/StrExt.h"
7 #include "AudioTools/AudioSource.h"
8 #include "AudioLibs/SDIndex.h"
36 AudioSourceIdxSDMMC(
const char *startFilePath =
"/",
const char *ext =
".mp3",
bool setupIndex=
true) {
37 start_path = startFilePath;
39 setup_index = setupIndex;
45 if (!SD_MMC.begin(
"/sdcard",
true)) {
46 LOGE(
"SD_MMC.begin failed");
51 idx.begin(start_path, exension, file_name_pattern, setup_index);
61 LOGI(
"nextStream: %d", offset);
66 LOGI(
"selectStream: %d",
index);
68 file_name = idx[
index];
69 if (file_name==
nullptr)
return nullptr;
70 LOGI(
"Using file %s", file_name);
71 file = SD_MMC.open(file_name);
72 return file ? &file :
nullptr;
77 file = SD_MMC.open(path);
78 file_name = file.name();
79 LOGI(
"-> selectStream: %s", path);
80 return file ? &file :
nullptr;
91 const char *
toStr() {
return file_name; }
97 virtual void setPath(
const char *p) { start_path = p; }
100 long size() {
return idx.size();}
106 const char *file_name;
107 const char *exension =
nullptr;
108 const char *start_path =
nullptr;
109 const char *file_name_pattern =
"*";
110 bool setup_index =
true;
111 bool is_sd_setup =
false;