I have video stream code with blobs and MediaRecorder. And I'm trying to rewrite my old code on es6.
If I call the method without brackets then this.property
does not work (returns undefined
). If I call the method with brackets, "e" stops working.
class testClass {
constructor() {
this.blobdata = [];
}
startRecording() {
this.mediaRecorder.ondataavailable = this.handleDataAvailable;
// this.handleDataAvailable if try like that - 'this.blobdata' returns undefined in handleDataAvailable(e)
// this.handleDataAvailable() if try like that - e.data return undefined...
}
handleDataAvailable(e) {
// there is error (this.blobdata returns undefined)
if (e.data && e.data.size > 0) this.blobdata .push(e.data)
}
}
let sc1 = new testClass();
let sc2 = new testClass();