Which audio format do both ios and android support

1,218 views
Skip to first unread message

Thomas Tveten

unread,
Mar 5, 2014, 7:24:01 AM3/5/14
to phon...@googlegroups.com
Hi, Im looking for a audio format that both android and ios supports. I have been pointed in many directions like this page: http://developer.android.com/guide/appendix/media-formats.html, and this https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/MultimediaPG/UsingAudio/UsingAudio.html#//apple_ref/doc/uid/TP40009767-CH2-SW6. However, when I record the audio on android as a wav, I get back audio/x-wav, when I record it as a mp3 I get back audio/mpeg. I can listen to the audio on android devices but not on ios. I have tried m4a, 3gp. mp4 m4v and so on. 

I upload the audio file to a server. I can play the audio ios are recording but not android. However, if I record in m4a format with android, Im able to play it in the browser, but not on the ios device. Can someone please help me?? 

I record the audio like this

               src = "recording.wav";

              mediaRec = new Media(src, onSuccess, onError);

get the file in the filesystem like this:

                      if(devicePlatform == "iOS"){
                      window.requestFileSystem(LocalFileSystem.TEMPORARY, 1024, gotFS, fail);
                      }
                      else if(devicePlatform == "Android"){
                      window.requestFileSystem(LocalFileSystem.PERSISTENT, 1024, gotFS, fail);
                      }

and get the base64 encoded string by doing this

function readDataUrl(file) {
         var reader = new FileReader();
        reader.onloadend = function(evt) {
            base = evt.target.result;
            document.getElementById("sendAudio").disabled = false;
            recordClicked = true;
        };
        reader.readAsDataURL(file);

     }

WebSteve

unread,
Mar 5, 2014, 10:35:22 AM3/5/14
to phon...@googlegroups.com
Please go to the android and iOS support pages and look through the audio docs. They'll tell you which formats and codecs they support. They are always your first resource.

Thomas Tveten

unread,
Mar 5, 2014, 10:43:37 AM3/5/14
to phon...@googlegroups.com
I have tried the different formats without any luck. I had to alter the phonegap media plugin to change the recordings attributes to this:

   this.recorder.setAudioSamplingRate(44100);
   this.recorder.setAudioEncodingBitRate(96000);
   this.recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
   this.recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);

But still, it does not work. I make the media objectby

               src = "recording.mp4"; // also tried mpeg4, m4v etc. 
              mediaRec = new Media(src, onSuccess, onError);

I have tried to create a media object to play it in ios by using the url (give back not supported). I try now to create a audio object with the url and the base64 ( no luck ). Can I create a media object with the base64?

Thomas Tveten

unread,
Mar 5, 2014, 10:47:08 AM3/5/14
to phon...@googlegroups.com
One other thing that bugs me. The base64 encoded string from the wav file recorded in ios is about 900 000 characters long, and on android only 20 000... Do you know if this is correct?

sim...@gmail.com

unread,
Mar 5, 2014, 1:20:02 PM3/5/14
to phon...@googlegroups.com
Hi Thomas,

I'm struggling with recording the audio on ios devices as it seemed that ios7 requires devices to grant permission to the application before I can start recording.

Do you mind sharing the part of code which you used to recording on ios?

I would be really appreciated if you can help me!

Simmy

Android Angel

unread,
Jun 10, 2014, 6:03:04 PM6/10/14
to phon...@googlegroups.com
Hi Thomas,
I try to record m4a on Android and it just does not work. Can you probably help me? I could record m4a on iOS without any issues... but it just does not work on android... :-(
Thanks!

ed wrede

unread,
Jun 11, 2014, 7:39:04 AM6/11/14
to phon...@googlegroups.com
I'd also be very interested in an answer to this.

I wrote an Android plugin which I use in a Cordova project which records to m4a, however I have not been able to test if this plays on an iOS device yet using the Cordova Media plugin to play the audio.

When I get a chance to test I'll update here.
Reply all
Reply to author
Forward
0 new messages