Look at this,
I have used the following package https://www.npmjs.com/package/ng-audio-recorder
And the following code is also following the example in the documentation
stopRecording() {
this.recorderState = RecorderState.STOPPING;
this.cdRef.detectChanges();
this.audioRecorderService
.stopRecording(OutputFormat.WEBM_BLOB)
.then((outputBlob: Blob) => {
if (outputBlob) {
this.currentBlob = outputBlob;
this.currentBlobUrl = URL.createObjectURL(outputBlob);
this.recorderState = this.audioRecorderService.getRecorderState();
this.cdRef.detectChanges();
}
})
.catch(errrorCase => {
console.log(errrorCase);
});
}
What am I doing wrong?
When you record audio using js, it is recorded as a stream of data. In my experience, all the streams behave like this in most of the audio/video players and only some of them were able to figure out the actual length. I suppose it is because the streams lack the metadata that gives the right information about these. Some players that managed to get the right information were professional editing tools, and I assume they somehow estimated the length with some other way. I really don't have any documentation that supports this reasoning but this is my best guess.
Edit: Turns out my assumptions were right and you can fix this by using this library I found on Github. Credits to daniel