title: Record Audio on Website that works on all browsers and iOS
body: <p>I have wasted a ton of time implementing multiple audio recording options in a website I'm building but each one either only works in Chrome, only in Firefox, both but not Safari, and none work on iOS. </p>
  
  <p>The website needs to allows the user to record their message and save it in a form state for submission. </p>
  
  <p>All the current articles I am reading are a few months old and mention that iOS doesn't/will support it soon. I've tried mobile Chrome on iOS and it still didn't work. </p>
  
  <p>Has anyone found a way to simply record audio in a browser as well as mobile website??</p>
  
  <p>Things I've tried:</p>
  
  <ul>
  <li>Francium Voice (An abandoned javascript project, works for Chrome. Records and saves and I am able to send the audio file through the form data. <a href="https://subinsb.com/html5-record-mic-voice/" rel="noreferrer">https://subinsb.com/html5-record-mic-voice/</a>. But this uses the &lt; audio > tag which shows as "error" and doesn't allow you to record. </li>
  <li>I started trying getUserMedia() as that seems to be the new standard and says it's supported on more devices/browsers but the mic wouldn't work on iOS either. <a href="https://www.html5rocks.com/en/tutorials/getusermedia/intro/" rel="noreferrer">https://www.html5rocks.com/en/tutorials/getusermedia/intro/</a></li>
  <li>Many articles say to use the Record.js, <a href="https://github.com/mattdiamond/Recorderjs" rel="noreferrer">https://github.com/mattdiamond/Recorderjs</a>, but that is also an abandoned project. I could only get the audio to record, but it wasn't saving it. Again not working in Safari or iOS. </li>
  <li>I tried using the audio/* technique but couldn't get it to work right. It would only show an upload button, couldn't get the mic option to show. Based on the documentation it seems like the one that "should" work though. <a href="https://developers.google.com/web/fundamentals/media/recording-audio/" rel="noreferrer">https://developers.google.com/web/fundamentals/media/recording-audio/</a></li>
  </ul>
  
  <p>Currently using the following code which works, for Chrome and Firefox.</p>
  
  <p>HTML</p>
  
  <p><code>&lt;audio controls src="" id="audio"&gt;&lt;/audio&gt;
  &lt;a class="button" id="record"&gt;Record&lt;/a&gt;
  &lt;input type="hidden" id="audiofile" name="audiofile" value="" aria-hidden="true"/&gt;</code></p>
  
  <p>Using the Francium Voice library:</p>
  
  <p>Javascript</p>
  
  <pre><code>    // Audio Recording for Phone Calls
    $(document).on("click", "#record:not(.stop)", function(){
    elem = $(this);
      $("#audio").attr("src","");
      $("#audiofile").val("");
    Fr.voice.record($("#live").is(":checked"), function(){
    elem.addClass("stop");
  });
      elem.html("Stop &lt;label id='minutes'&gt;00&lt;/label&gt;:&lt;label   id='seconds'&gt;00&lt;/label&gt;");
      var minutesLabel = document.getElementById("minutes");
      var secondsLabel = document.getElementById("seconds");
      var totalSeconds = 0;
      setInterval(setTime, 1000);
  
      function setTime() {
          ++totalSeconds;
          secondsLabel.innerHTML = pad(totalSeconds % 60);
          minutesLabel.innerHTML = pad(parseInt(totalSeconds / 60));
      }
  
      function pad(val) {
          var valString = val + "";
          if (valString.length &lt; 2) {
              return "0" + valString;
          } else {
              return valString;
          }
      }
  });
  
  $(document).on("click", ".stop", function(){
      elem = $(this);
      elem.html("Record");
      elem.removeClass("stop");
  Fr.voice.export(function(base64){
    $("#audio").attr("src", base64);
          $("#audiofile").val(base64);
          $("#audio")[0].play();
  }, "base64");
      Fr.voice.stop();
  });  
  </code></pre>