add stream restart to recorder
This commit is contained in:
parent
37764bb3a0
commit
a534964b96
1 changed files with 20 additions and 17 deletions
|
|
@ -12,11 +12,11 @@ interface RecorderI {
|
||||||
}
|
}
|
||||||
|
|
||||||
type inputOptions = {
|
type inputOptions = {
|
||||||
channelCount: number,
|
channelCount: number;
|
||||||
sampleFormat: number,
|
sampleFormat: number;
|
||||||
sampleRate: number,
|
sampleRate: number;
|
||||||
deviceId: number,
|
deviceId: number;
|
||||||
closeOnError: boolean
|
closeOnError: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
class StringWritable extends Writable {
|
class StringWritable extends Writable {
|
||||||
|
|
@ -55,9 +55,13 @@ export class Recorder implements RecorderI {
|
||||||
this.recorderOptions = options;
|
this.recorderOptions = options;
|
||||||
this.micWritable = new StringWritable({
|
this.micWritable = new StringWritable({
|
||||||
defaultEncoding: encoding
|
defaultEncoding: encoding
|
||||||
})
|
});
|
||||||
this.restart();
|
try {
|
||||||
ipcMain.on('update-recorder', this._update);
|
this.restart();
|
||||||
|
ipcMain.on('update-recorder', this._update);
|
||||||
|
} catch(e) {
|
||||||
|
console.log('MEGA ERROR!');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
restart() {
|
restart() {
|
||||||
|
|
@ -94,23 +98,22 @@ export class Recorder implements RecorderI {
|
||||||
if (record) {
|
if (record) {
|
||||||
// check for stream status
|
// check for stream status
|
||||||
console.log('recording')
|
console.log('recording')
|
||||||
|
this.resume();
|
||||||
|
|
||||||
// this.ia.pipe(this.micWritable);
|
// this.ia.pipe(this.micWritable);
|
||||||
} else {
|
} else {
|
||||||
console.log('stop recording')
|
console.log('stop recording')
|
||||||
// unpipe
|
// unpipe
|
||||||
// this.ia.unpipe(this.micWritable);
|
this.ia.unpipe(this.micWritable);
|
||||||
|
|
||||||
// stop stream
|
// stop stream
|
||||||
// this.ia.quit();
|
this.ia.quit();
|
||||||
// this.ia = null;
|
this.ia = null;
|
||||||
|
|
||||||
// get stream data
|
// get stream data
|
||||||
// this.micWritable.on('finish', () => {
|
this.micWritable.on('finish', () => {
|
||||||
// console.log('finished writing data');
|
console.log('finished writing data');
|
||||||
// })
|
})
|
||||||
// this.restart();
|
this.restart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue