Reputation: 4742
In Angular 8, I want to convert audio captured through browser to ogg format. For that, I'm using opus-recorder library: https://github.com/chris-rudmin/opus-recorder
I did npm install opus-recorder
const opusRecorder = require('opus-recorder');
startRecording() {
var options = {
encoderPath: './assets/encoderWorker.min.js'
};
let recorder = new opusRecorder.Recorder(options);
recorder.start().catch(function(e) {
console.log('Error encountered:', e.message );
});
}
The github repository says that The Recorder object is available in the global namespace and supports CommonJS and AMD imports.
I get the following error when I call startRecording():
ERROR TypeError: opusRecorder.Recorder is not a constructor
Am I using the library correctly? Am I importing it correctly? Can it be used in Angular?
Upvotes: 3
Views: 559
Reputation: 4742
I solved it by doing import * as opusRecorder from 'opus-recorder';
and then let recorder = new opusRecorder1(options);
Upvotes: 1