作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试通过 React 应用程序从浏览器录制 wav 并将其发送到我的 nodeJS API。这在原型(prototype) html5 示例中运行良好。但现在我正在将它移动到 React/Typescript。我对 typescript 还很陌生,所以一切都感觉有点老套。
我正在使用 RecordRTC,到目前为止的代码是:
声明文件,因为 recordRTC 没有 @types/recordrtc:
declare module "recordrtc";
实际代码:
startRecording() {
this.record = true
this.captureUserMedia((stream: any) => {
this.recordAudio = RecordRTC(stream, { recorderType: 'StereoAudioRecorder', type: 'audio', mimeType: 'audio/wav' });
this.recordAudio.startRecording();
});
}
当我调用 startRecording 时,我得到了这个:
Uncaught TypeError: Recorder is not a constructor
at initRecorder (RecordRTC.js:87)
at Object.startRecording (RecordRTC.js:70)
at PracticeScreen.tsx:143
在 chrome 浏览器中显示的是:
最佳答案
The RecordRTC documentation显示 recorderType
需要一个类构造函数,但您的示例将其设置为一个字符串。您可以将其设置为 StereoAudioRecorder 的类构造函数像这样:
RecordRTC(
stream,
{
recorderType: StereoAudioRecorder, // <-------- class constructor not string
type: 'audio',
mimeType: 'audio/wav'
},
);
关于javascript - RTC记录器: TypeError Recorder is not a constructor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57732632/
我是一名优秀的程序员,十分优秀!