3#include "AudioLogger.h"
4#include "AudioTools/Disk/AudioSource.h"
5#include "AudioTools/AudioLibs/Desktop/File.h"
6#include "AudioTools/CoreAudio/AudioBasic/StrView.h"
11namespace fs = std::filesystem;
23 start_path = startFilePath;
25 timeout_auto_next_value = 600000;
43 LOGI(
"nextStream: %d", offset);
45 if (s ==
nullptr && offset > 0) {
46 LOGI(
"Wrapping to start of directory");
56 LOGI(
"selectStream: %d of %d",
index, (
int) count);
58 LOGW(
"No audio files found under: %s", start_path ? start_path :
"<null>");
61 int norm =
index % count;
62 if (norm < 0) norm += count;
64 file_name = get(norm);
65 if (file_name==
nullptr) {
66 LOGW(
"Could not resolve index %d (normalized %d)",
index, norm);
69 LOGI(
"Using file %s", file_name);
71 file = SD.open(file_name);
72 return file ? &file :
nullptr;
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; }
102 for (
auto const& dir_entry : fs::recursive_directory_iterator(start_path)){
113 const char *file_name;
114 std::string current_path;
115 const char *exension =
"";
116 const char *start_path =
nullptr;
117 const char *file_name_pattern =
"*";
118 fs::directory_entry entry;
121 const char* get(
int idx){
123 const char* result =
nullptr;
124 for (
auto const& dir_entry : fs::recursive_directory_iterator(start_path)){
128 current_path = entry.path().string();
129 result = current_path.c_str();
139 const std::filesystem::path path = file.path();
140 const std::string filename = path.filename().string();
141 const char *file_name_c = filename.c_str();
142 if (file.is_directory()) {
143 LOGD(
"-> isValidAudioFile: '%s': %d", file_name_c,
false);
146 StrView strFileTName(file_name_c);
148 && strFileTName.
matches(file_name_pattern);
149 LOGD(
"-> isValidAudioFile: '%s': %d", file_name_c, result);