0

This code is working fine for playing '.mp3' and '.wav' file, but it's not supporting '.ulaw' format. I went through several plugins but it didn't help me. Is there any way to run the '.ulaw' audio, or convert '.ulaw' to other formats?

Below 'src' is path to ulaw audio

<audio
ref={ref}
src={src}
controls
onPlay={() => setPlaying(true)}
onPause={() => setPlaying(false)}
onTimeUpdate={onTimeUpdate}
/>
u_pendra
  • 908
  • 1
  • 10
  • 25

1 Answers1

1

This has nothing to do with React, you're using the HTML audio tag, which plays audio from sources that the browsers understand. Browsers differ in which audio file types they can play, which you can see here: https://en.wikipedia.org/wiki/HTML5_audio

To play a ulaw file, you'll need to convert it to a supported type first, eg. mp3, wav, or ogg. To do this, there are many online converters available with a quick web search. Alternatively you could use ffmpeg, a common open-source tool, to convert the file in terminal, eg.:

ffmpeg.exe -f mulaw -ar 44100 -i inputfile.ulaw outputfile.wav
frozen
  • 2,114
  • 14
  • 33
  • In system I am able to convert and play this audio, but I need to convert it programmatically in reactjs, https://stackoverflow.com/questions/67952243/how-to-convert-ulaw-format-file-to-wav-format-reactjs – u_pendra Jun 12 '21 at 19:45