diff --git a/src/DirectoryNode.cpp b/src/DirectoryNode.cpp index bce5ddd..5a1e312 100644 --- a/src/DirectoryNode.cpp +++ b/src/DirectoryNode.cpp @@ -122,6 +122,36 @@ void DirectoryNode::advanceToFirstMP3InThisNode() { } } +DirectoryNode* DirectoryNode::advanceToMP3(const String* currentGlobal) { + for (auto subdir : subdirectories) + { + if (subdir->getName()==*currentGlobal) { + subdir->advanceToFirstMP3InThisNode(); + return subdir; + } + + // Have each subdirectory advance its song + for (size_t i = 0; i < subdir->mp3Files.size(); i++) + { + if (*currentGlobal == subdir->mp3Files[i]) + { + // Found the current MP3 file + if (i < subdir->mp3Files.size() - 1) + { + subdir->currentPlaying = &subdir->mp3Files[i]; + return subdir; + } + + } + } + } + + // If we get here, there were no MP3 files or subdirectories left to check + currentPlaying = nullptr; + Serial.println("no more nodes found"); + return this; +} + DirectoryNode* DirectoryNode::advanceToNextMP3(const String* currentGlobal) { bool useFirst = false; diff --git a/src/DirectoryNode.h b/src/DirectoryNode.h index 5eaadbe..f73c685 100644 --- a/src/DirectoryNode.h +++ b/src/DirectoryNode.h @@ -26,6 +26,7 @@ public: void addMP3File(const String& mp3File); void buildDirectoryTree(const char* currentPath); void printDirectoryTree(int level = 0) const; + DirectoryNode* advanceToMP3(const String* currentGlobal); DirectoryNode* advanceToNextMP3(const String* currentGlobal); void advanceToFirstMP3InThisNode(); String getDirectoryStructureHTML() const; diff --git a/src/WebContent.h b/src/WebContent.h index debf04e..c3f007b 100644 --- a/src/WebContent.h +++ b/src/WebContent.h @@ -39,6 +39,16 @@ const char index_html[] PROGMEM = R"rawliteral(





+
+ +
+ + +
+
+ +
+

Content of SD Card:

%DIRECTORY% @@ -46,6 +56,19 @@ const char index_html[] PROGMEM = R"rawliteral(