5 #include "AudioLogger.h"
6 #include "AudioTools/CoreAudio/AudioSource.h"
7 #include "AudioTools/AudioLibs/SDIndex.h"
35 AudioSourceIdxSDMMC(
const char *startFilePath =
"/",
const char *ext =
".mp3",
bool setupIndex=
true) {
36 start_path = startFilePath;
38 setup_index = setupIndex;
44 if (!SD_MMC.begin(
"/sdcard",
true)) {
45 LOGE(
"SD_MMC.begin failed");
50 idx.begin(start_path, exension, file_name_pattern, setup_index);
60 LOGI(
"nextStream: %d", offset);
65 LOGI(
"selectStream: %d",
index);
67 file_name = idx[
index];
68 if (file_name==
nullptr)
return nullptr;
69 LOGI(
"Using file %s", file_name);
70 file = SD_MMC.open(file_name);
71 return file ? &file :
nullptr;
76 file = SD_MMC.open(path);
77 file_name = file.name();
78 LOGI(
"-> selectStream: %s", path);
79 return file ? &file :
nullptr;
90 const char *
toStr() {
return file_name; }
96 virtual void setPath(
const char *p) { start_path = p; }
99 long size() {
return idx.size();}
105 const char *file_name;
106 const char *exension =
nullptr;
107 const char *start_path =
nullptr;
108 const char *file_name_pattern =
"*";
109 bool setup_index =
true;
110 bool is_sd_setup =
false;