Mobile Safari中Javascript中的麦克风访问

问题描述 投票:3回答:1

我正在尝试在网页中实现对Java麦克风的访问,

同时使用navigator.getUserMedia({audio: true})navigator.mediaDevices.getUserMedia({audio:true})

((并检查供应商前缀:

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

响应于页面上按钮的点击事件而调用

似乎在IOS Safari中不起作用。 (在桌面版Chrome中可以正常运行)。

但是these guys在这里似乎可以正常工作-它可以在我的iPhone上的Safari上运行。

他们在做什么不同?

javascript ios safari microphone getusermedia
1个回答
0
投票

[enter image description here我们可以在输入文本框中输入键盘麦克风,并在用户停止询问时以编程方式触发某些功能]]

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">
© www.soinside.com 2019 - 2024. All rights reserved.