javascript - js获取部分直播的base64
问题描述
我正在尝试将当前录制的语音的 base64 字符串发送到服务器进行其他处理。我的方法是将base64字符串推送到recordedChunks中进行查询然后发送到服务器。
const recordedChunks = [];
var context = null;
var blob = null;
const handler = function(stream) {
if (window.URL) {
player.srcObject = stream;
} else {
//player.src = stream;
}
const context = new AudioContext();
const source = context.createMediaStreamSource(stream);
let bufferSize=1024;
const processor = context.createScriptProcessor(bufferSize, 1, 1);
source.connect(processor);
processor.connect(context.destination);
processor.onaudioprocess = function(e) {
//e.inputBuffer
// Do something with the data, e.g. convert it to mp3
// How to get base64 of what has been recorded without stopping the recorder
// recordedChunks.push('somePrerecodedBase64String');
};
};
navigator.mediaDevices.getUserMedia({ audio: true, video: false })
.then(handler);
解决方案
推荐阅读
- terraform - terraform alicloud 创建 alicloud_cs_managed_kubernetes 失败
- javascript - 用户键入时引导 4 表单验证
- oracle - 从 PROCEDURE BY SELECT 返回 REF CURSOR
- javascript - Reacts useEffects 详尽的 deps 仅触发创建组件将卸载功能
- python - 使用 matplotlib 在 3d 表面上绘制相交的 2d 平面
- javascript - 在 redux-saga 中获取数据后如何在组件中调用渲染?
- typescript - 自定义属性名称
- jquery - jquery按单元格中的列基础内容对表格进行排序
- shibboleth - shibsp::ConfigurationException,为什么服务提供商没有记录任何附加信息?
- log4j2 - 以编程方式更改日志级别