Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play audio file of any format in any browser

I am recording audio in different mobiles and each saves the file in different format like

.m4a, .3ga, .amr

. The problem now I am facing is how to play such audio files in any browser.

<audio controls height="100" width="100">
  <source src="myfile.mp3" type="audio/mpeg">
  <source src="myfile.ogg" type="audio/ogg">
  <embed height="50" width="100" src="myfile.mp3">
</audio>

I tried the above code, but not useful. because I am unable to apply the code for .m4a, .3ga and .amr.

Phone recordings wont be in mp3 files for sure

Any other approach I need to apply ?

Any suggestions ? Please

like image 811
Deepanshu Goyal Avatar asked Nov 01 '22 16:11

Deepanshu Goyal


1 Answers

I'm sorry to bring you the bad news, but you can't play any file format in a <audio> HTML5 element.
Instead, you can choose from a list of valid audio formats as listed here: https://developer.mozilla.org/en-US/docs/Web/HTML/Supported_media_formats

Shortly, the valid formats are:

  1. WebM
  2. Ogg
  3. MP3
  4. AAC
  5. WAV

In your case, if you would like to play any audio format that isn't supported by the HTML5 spec, you will have to solve it, the same way audio files were played before HTML5, by using Plugins.
You can find on the web lots of audio-plugins for the browser, for each type of file format.

like image 173
Gil Epshtain Avatar answered Jan 04 '23 13:01

Gil Epshtain