0

So I would like to host audio files on my server.

Here's how I do it.

app.use("/media/audio", express.static("media/audio"));

I have done it tons of times with images and I really haven't had a problem so far.

I am able to play these files in browser but I need little more than that.

I am not even sure how to describe it but what I need is this:

enter image description here

My URL only returns media player but nothing in Sources tab like shown in the picture.

The only reason I want it is because Android MediaPlayer cannot return .mp3 file just because the URL ends with .mp3. Apple doesn't have a problem with that and it plays fine.

Ajay Dabas
  • 1,404
  • 1
  • 5
  • 15
Ivalo Pajumets
  • 437
  • 6
  • 11
  • If I'm not wrong, you want to play it accordingly to the device, so you should try write the response based on your device type (using nodejs filesystem): https://stackoverflow.com/a/50537909/3332734 – Francis Rodrigues Jan 20 '20 at 00:43
  • In case you want to retrieve the duration of a MP3/WAV Audio File in the Browser: https://ourcodeworld.com/articles/read/1036/how-to-retrieve-the-duration-of-a-mp3-wav-audio-file-in-the-browser-with-javascript – Francis Rodrigues Jan 20 '20 at 00:47

1 Answers1

0

instead of app.use("/media/audio", express.static("media/audio"));

use

app.use("/media/audio", (req, res)=>{
  res.download("/media/audio.mp3");
});
Vinil Prabhu
  • 1,279
  • 1
  • 10
  • 22