Parag Jain
Parag Jain

Reputation: 662

Start working with audio API with Web : Code is working is desktop browser but not working in mobile browser

Below given code is for recording audio from browser and play at the same moment. My problem is this code is working on desktop browser but not working on mobile browser using Chrome browser in both platform with latest version. Can any one help me with this?

<audio id="player" controls></audio>
<script>
  const player = document.getElementById('player');

  const handleSuccess = function(stream) {

    if (window.URL) {
      player.srcObject = stream;
    } else {
      player.src = stream;
    }
  };

  navigator.mediaDevices.getUserMedia({ audio: true, video: false })
      .then(handleSuccess);
</script>

Upvotes: 1

Views: 51

Answers (1)

Parag Jain
Parag Jain

Reputation: 662

navigator.mediaDevices.getUserMedia will not work without SSL in mobile browser so I have installed SSL on my localhost and now it is working.

Upvotes: 1

Related Questions