title: Is it possible to record audio in iOS with Codename One?
body: <p>My app features a button to record audio (and another to play it back when the recording is over). I send the recorded audio files on a server. On Android the files is recorded as .amr (mime type audio/amr) and can be played back.</p>
  
  <p>On iOS however the file can neither be played back on the device (iPhone 4 or 4S) nor on a computer. <code>ffmpeg -i</code> reports </p>
  
  <pre><code>[mov,mp4,m4a,3gp,3g2,mj2 @ 0x2fac120] moov atom not found
  9gMjOnnmsj9JJZR3.m4a: Invalid data found when processing input
  </code></pre>
  
  <p><em>Please note that VLC cannot play it either.</em></p>
  
  <p>I give the m4a extension because Voice recorder uses it (along with aac codec).</p>
  
  <p>Here is the code I use (mostly based on <a href="https://github.com/codenameone/CodenameOne/blob/master/Ports/iOSPort/src/com/codename1/impl/ios/IOSImplementation.java#L2768-L2794" rel="nofollow noreferrer">https://github.com/codenameone/CodenameOne/blob/master/Ports/iOSPort/src/com/codename1/impl/ios/IOSImplementation.java#L2768-L2794</a> ) :</p>
  
  <pre><code>audioMemoPath = ParametresGeneraux.getWRITABLE_DIR() + "AudioMemo-"
              + System.currentTimeMillis() + 
              (Display.getInstance().getPlatformName().equals("and")
              ? ".amr"
              : ".m4a");
  audioMemoMimeType = MediaManager.getAvailableRecordingMimeTypes()[0];
  
  audioMemoRecorder = MediaManager.createMediaRecorder(audioMemoPath, audioMemoMimeType);
  
  // If the permission audio has not been granted 
  // the audiomemorecoreder will be null
       if (audioMemoRecorder != null) {
             audioMemoRecorder.play();
             boolean b = Dialog.show("Recording", "", "Save", "Cancel");
             audioMemoRecorder.pause();
             audioMemoRecorder.cleanup();
  
              ...
          }
  </code></pre>
  
  <p>Moreover if I display the available mime types on iOS, it yields "audio/amr" which I doubt according to all the posts I could read that tell you amr is not supported on iOS. Looking at the source it appears amr is the by default mime type because it is always returned :</p>
  
  <pre><code>/**
   * Gets the available recording MimeTypes
   */ 
  public String [] getAvailableRecordingMimeTypes(){
      return new String[]{"audio/amr"};
  }
  </code></pre>
  
  <p>So my question : is it possible to record audio on iOS, and if it is, how can it be done ?</p>
  
  <p>Any help appreciated,</p>