diff --git a/src/core/sd_functions.cpp b/src/core/sd_functions.cpp index 5feb2483..126a5bf8 100644 --- a/src/core/sd_functions.cpp +++ b/src/core/sd_functions.cpp @@ -2,6 +2,7 @@ #include "sd_functions.h" #include "mykeyboard.h" // usinf keyboard when calling rename #include "display.h" // using displayRedStripe as error msg +#include "../modules/others/audio.h" struct FilePage { int pageIndex; @@ -495,6 +496,14 @@ String loopSD(FS &fs, bool filePicker, String allowed_ext) { if(&fs == &SD) options.push_back({"Copy->LittleFS", [=]() { copyToFs(SD,LittleFS, fileList[index][1]); }}); if(&fs == &LittleFS && sdcardMounted) options.push_back({"Copy->SD", [=]() { copyToFs(LittleFS, SD, fileList[index][1]); }}); + #if defined(HAS_NS4168_SPKR) + if(isAudioFile(fileList[index][1])) options.push_back({"Play Audio", [=]() { + playAudioFile(const_cast(&fs), fileList[index][1]); + setup_gpio(); //TODO: remove after fix select loop + + }}); + #endif + options.push_back({"Main Menu", [=]() { backToMenu(); }}); delay(200); if(!filePicker) loopOptions(options); diff --git a/src/core/sd_functions.h b/src/core/sd_functions.h index 691df8e8..22e8f50b 100644 --- a/src/core/sd_functions.h +++ b/src/core/sd_functions.h @@ -4,6 +4,7 @@ #include + extern SPIClass sdcardSPI; bool setupSdCard(); diff --git a/src/modules/others/audio.cpp b/src/modules/others/audio.cpp index 842485d9..159c5556 100644 --- a/src/modules/others/audio.cpp +++ b/src/modules/others/audio.cpp @@ -111,4 +111,10 @@ bool tts(String text){ return true; } + +bool isAudioFile(String filepath) { + + return filepath.endsWith(".txt") || filepath.endsWith(".rtttl") || + filepath.endsWith(".wav") || filepath.endsWith(".mod") || filepath.endsWith(".mp3") ; +} #endif diff --git a/src/modules/others/audio.h b/src/modules/others/audio.h index 08256ec3..272dfb5e 100644 --- a/src/modules/others/audio.h +++ b/src/modules/others/audio.h @@ -7,4 +7,6 @@ bool playAudioFile(FS* fs, String filepath); // TODO: bool async arg -> play in bool playAudioRTTTLString(String song); -bool tts(String text); \ No newline at end of file +bool tts(String text); + +bool isAudioFile(String filePath); \ No newline at end of file