如何从设备麦克风录制音频并将其发送到服务器

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

我想使用Cordova使用设备麦克风录制音频。我需要与其他用户共享记录的输入-使用HTTP请求将其发送到我的API。

是否有用于此的插件?我还没找到什么是RAW音频数据?我已经看到一些使用此插件的插件,但我实际上并不了解-它像图像缓冲区一样,可以使用常规HTTP请求发送此数据,并且用户浏览器会将其转换为声音吗?是否可以在用户讲话时播放声音,而不必像通话一样等待他完成整个录音?

[请给我一些相关信息,或链接到可用的插件,因为在本节中我没有找到任何插件。

android ios cordova audio-recording microphone
1个回答
0
投票

使用此插件cordova plugin add cordova-plugin-media-capture

// capture callback
var captureSuccess = function(mediaFiles) {
    for (var i = 0, i < mediaFiles.length; i++) {
        var filePath = mediaFiles[i].fullPath;
        // Do somthing
        // Http Request
    }
};

// capture error callback
var captureError = function(error) {
    console.log(error.code);
};

// start capture
navigator.device.capture.captureAudio(captureSuccess, captureError, {limit:1});
© www.soinside.com 2019 - 2024. All rights reserved.