How to pass an mp3 to an esp32 to an html browser

I have an html webserver that is running on an esp32 and on that html i need play an audio file. the audio file is stored in an SD card that is connected to the ESP32

how do i pass this audio file to the browser?

in the browser i have this

<audio controls autoplay>
  <source src=" http://192.168.4.1/background1.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>

and in the esp server

  server.on("/background1", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send(SD, "/background1.mp3", "audio/mpeg");
  });

The mp3 file is on the sd card, and its filename is background1.mp3. but the browser is not able to play the mp3

image

What does the browser developer tools say? Does it try to load the MP3? Does it try to load a range?

Post complete code, usually the error is in that part of the code people are hiding from us.

One thing I would try is changing to:
server.on("/background1.mp3", HTTP_GET,

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.