Microphone access in Javascript in Mobile Safari

Viewed 2009

I'm trying to implement access to the microphone in Javascript, in a webpage,

using both navigator.getUserMedia({audio: true}) or navigator.mediaDevices.getUserMedia({audio:true})

(and implementing a check for vendor prefixes:

navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia; )

which is called in response to a click event of a button on the page

doesn't seem to work in IOS Safari. (Works ok in desktop Chrome).

However, these guys here seem to get it working - it works on Safari on my iPhone.

What are they doing different?

1 Answers

enter image description herewe can you keypad microphone in input textbox and programmatically trigger some function when user stops asking

var prevTextboxWords = "";
    var textboxWords = "";
    var textRepeatTimes = 0;
    var prevTextCheck = "";
    var textCheck = "";
    var textCheckNumber = 0;
    var x = 0;
    var speechTimeOutLimit = 16;
    var iOS = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform);
    if (iOS) {
        iosVoice();

        function iosVoice() {
            setTimeout(function() {
                textCheck = $("#record").val();
                var numberOfWordsSpoken = textCheck.split(" ").length;
                if (numberOfWordsSpoken < 3) speechTimeOutLimit = 16;
                else if (numberOfWordsSpoken < 6) speechTimeOutLimit = 12;
                else speechTimeOutLimit = 7;
                if (textCheck != "" && textCheck == prevTextCheck) {
                    textCheckNumber++
                } else {
                    textCheckNumber = 0
                }
                if (textCheck.length < 4) textCheckNumber = 0;
                if (textCheckNumber > speechTimeOutLimit) {
                    textCheckNumber = 0;
                    $("#record").val("");
                    prevTextCheck = "";
                    textCheck = textCheck.toLowerCase();

                    console.log(textCheck + "HIT");


                    //some function with text textCheck

                   
                    

    
                    textCheck = ""
                }
                prevTextCheck = textCheck;
                coroverIosVoice()
            }, 200)
        }
    }
<input type="text" id="record">

Related