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;
38 LOGI(
"nextStream: %d", offset);
40 if (s ==
nullptr && offset > 0) {
41 LOGI(
"Wrapping to start of directory");
51 LOGI(
"selectStream: %d of %d",
index, (
int) count);
53 LOGW(
"No audio files found under: %s", start_path ? start_path :
"<null>");
56 int norm =
index % count;
57 if (norm < 0) norm += count;
59 file_name = get(norm);
60 if (file_name==
nullptr) {
61 LOGW(
"Could not resolve index %d (normalized %d)",
index, norm);
64 LOGI(
"Using file %s", file_name);
66 file = SD.open(file_name);
67 return file ? &file :
nullptr;
73 file_name = file.name();
74 LOGI(
"-> selectStream: %s", path);
75 return file ? &file :
nullptr;
86 const char *
toStr() {
return file_name; }
92 virtual void setPath(
const char *p) { start_path = p; }
97 for (
auto const& dir_entry : fs::recursive_directory_iterator(start_path)){
108 const char *file_name;
109 std::string current_path;
110 const char *exension =
"";
111 const char *start_path =
nullptr;
112 const char *file_name_pattern =
"*";
113 fs::directory_entry entry;
116 const char* get(
int idx){
118 const char* result =
nullptr;
119 for (
auto const& dir_entry : fs::recursive_directory_iterator(start_path)){
123 current_path = entry.path().string();
124 result = current_path.c_str();
134 const std::filesystem::path path = file.path();
135 const std::string filename = path.filename().string();
136 const char *file_name_c = filename.c_str();
137 if (file.is_directory()) {
138 LOGD(
"-> isValidAudioFile: '%s': %d", file_name_c,
false);
141 StrView strFileTName(file_name_c);
143 && strFileTName.
matches(file_name_pattern);
144 LOGD(
"-> isValidAudioFile: '%s': %d", file_name_c, result);