3 #include "AudioBasic/StrExt.h"
4 #include "AudioLogger.h"
5 #include "AudioTools/AudioSource.h"
8 #include "AudioLibs/SDDirect.h"
36 AudioSourceSDMMC(
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);
62 LOGI(
"nextStream: %d", offset);
67 LOGI(
"selectStream: %d",
index);
69 file_name = idx[
index];
70 if (file_name==
nullptr)
return nullptr;
71 LOGI(
"Using file %s", file_name);
72 file = SD_MMC.open(file_name);
73 return file ? &file :
nullptr;
78 file = SD_MMC.open(path);
79 file_name = file.name();
80 LOGI(
"-> selectStream: %s", path);
81 return file ? &file :
nullptr;
92 const char *
toStr() {
return file_name; }
98 virtual void setPath(
const char *p) { start_path = p; }
107 const char *file_name;
108 const char *exension =
nullptr;
109 const char *start_path =
nullptr;
110 const char *file_name_pattern =
"*";
111 bool setup_index =
true;
112 bool is_sd_setup =
false;