earlephilhower / ESP8266Audio

Arduino library to play MOD, WAV, FLAC, MIDI, RTTTL, MP3, and AAC files on I2S DACs or with a software emulated delta-sigma DAC on the ESP8266 and ESP32
GNU General Public License v3.0
2.03k stars 432 forks source link

fatal error: LittleFS.h: No such file or directory on esp32 #596

Closed tonyxforce closed 1 year ago

tonyxforce commented 1 year ago

im using this code that i got from chatgpt:

#include <ESP8266Audio.h>
#include <SPIFFS.h>

#define MP3_FILE "/song.mp3"

// Create an instance of the AudioFileSourceSPIFFS class to read the MP3 file from SPIFFS
AudioFileSourceSPIFFS *file;

// Create an instance of the AudioGeneratorMP3 class to decode the MP3 data
AudioGeneratorMP3 *mp3;

// Create an instance of the AudioOutputI2S class to output the audio to the DAC
AudioOutputI2S *out;

void setup() {
  // Initialize SPIFFS
  if (!SPIFFS.begin()) {
    Serial.println("Error mounting SPIFFS");
    return;
  }

  // Open the MP3 file
  file = new AudioFileSourceSPIFFS(MP3_FILE);
  if (!file) {
    Serial.println("Error opening MP3 file");
    return;
  }

  // Initialize the audio output
  out = new AudioOutputI2S();
  if (!out->begin()) {
    Serial.println("Error initializing audio output");
    return;
  }

  // Initialize the MP3 decoder
  mp3 = new AudioGeneratorMP3();
  if (!mp3->begin(file, out)) {
    Serial.println("Error initializing MP3 decoder");
    return;
  }
}

void loop() {
  // Run the MP3 decoder
  mp3->loop();
}

that reads an mp3 file from spiffs, decodes it and then writes it out to the internal dac (pin 25)

what is wrong?

the full error:

In file included from C:\Users\Domi\Documents\Arduino\libraries\ESP8266Audio-master\src/ESP8266Audio.h:13:0,
                 from C:\Users\Domi\Documents\Arduino\esp32playmp3\esp32playmp3.ino:1:
C:\Users\Domi\Documents\Arduino\libraries\ESP8266Audio-master\src/AudioFileSourceLittleFS.h:25:22: fatal error: LittleFS.h: No such file or directory
earlephilhower commented 1 year ago

I suggest you look at the examples instead of asking ChatGPT to come up with a working program. We have a couple MP3 playing ones already that are proven to work. Good luck.