0

我正在构建一个约会安排网络应用程序(类似于日历),它允许用户在某些时间点留下语音消息(解释),其他人可以在他们方便的时候远程检索。它在PC上运行良好,但我无法让它在手机上运行。显然,新的安全上下文标准已经到位(WebRTC?)并且必须提供安全上下文,但是尽管我使用的是 HTTPS(SSL 站点/域),但我无法让它在任何主要浏览器中工作。我还能如何提供这样的安全上下文?

我附上的代码非常流行并且过去运行良好(它仍然在笔记本电脑上运行!)。我该怎么做才能在手机(IOS、Android、平板电脑)上提供正确的上下文?感谢您的任何帮助。

navigator.mediaDevices.getUserMedia(constraints).then(function(stream) {
        //console.log("getUserMedia() success, stream created, initializing Speakit_recorder.js ...");
        audioContext = new AudioContext();
        //update the format 
        /*  assign to gumStream for later use  */
        gumStream = stream;
        /* use the stream */
        input = audioContext.createMediaStreamSource(stream);
        /* Create the Recorder object, configure to record mono sound(1channel). Recording 2channels  will double the file size */
        rec = new Recorder(input,{numChannels:2})
        //start the recording process                       
        rec.record();
        //console.log("Recording started");
}).catch(function(err) {                
        //do whatever is necesssary if getUserMedia() fails
});
4

1 回答 1

0

可能是由于 Chrome 71 中的自动播放更改所致。请参阅https://developers.google.com/web/updates/2017/09/autoplay-policy-changes以及https://bugs.chromium.org /p/chromium/issues/detail?id=835767了解详情。

您可能想要记录 audioContext.state 是“正在运行”。如果没有,您需要在用户操作(例如按钮单击)上调用 audioContext.resume()

于 2019-04-26T20:33:13.467 回答