From 5a3cd6004655a1ff1d9b56f28f475e5bb179d37c Mon Sep 17 00:00:00 2001 From: Enrique Hernandez Date: Fri, 11 Dec 2020 10:41:52 -0600 Subject: [PATCH] add audioRenderer + ipc event listeners --- src/background.ts | 57 ++++++---- src/components/UI/UIDetails/inputItem.vue | 46 +++++--- .../audioRenderer/useAudioRenderer.ts | 35 ++---- .../streamRecorder/useStreamRecorder.ts | 103 ++++++++++++++++-- src/preload.ts | 12 ++ 5 files changed, 180 insertions(+), 73 deletions(-) diff --git a/src/background.ts b/src/background.ts index 53227e0..6b1284a 100644 --- a/src/background.ts +++ b/src/background.ts @@ -1,6 +1,6 @@ "use strict"; -import { app, protocol, BrowserWindow } from "electron"; +import { app, protocol, BrowserWindow, ipcMain } from "electron"; import { createProtocol } from "vue-cli-plugin-electron-builder/lib"; import installExtension, { VUEJS_DEVTOOLS } from "electron-devtools-installer"; const isDevelopment = process.env.NODE_ENV !== "production"; @@ -56,26 +56,41 @@ function createWindow() { win.loadURL("app://./index.html"); } - // win.webContents.on('did-finish-load', () => { - // if (win) { - // recorder.start({ - // onAudio: (audio: object, speech: boolean) => { - // if (win) { - // win.setTitle("Listening..."); - // // win.webContents.send('render-audio', { - // // audio: audio, - // // speech: speech - // // }) - // if (speech) { - // win.setTitle("Recording..."); - // // TODO: send audio to crimata BE - // // ws.send(audio); - // } - // } - // } - // }); - // } - // }) + + win.webContents.on('did-finish-load', () => { + // ipcMain.on('audio-stream', (Event: any, Payload: any) => { + // if (Payload.stream) { + // console.log('begin streaming'); + // recorder.start({ + // onAudio: (audio: object, speech: boolean) => { + // console.log(audio) + // } + // }); + // } else { + // recorder.stop(); + // console.log('stop streaming') + // } + // }) + + // if (win) { + // recorder.start({ + // onAudio: (audio: object, speech: boolean) => { + // if (win) { + // win.setTitle("Listening..."); + // // win.webContents.send('render-audio', { + // // audio: audio, + // // speech: speech + // // }) + // if (speech) { + // win.setTitle("Recording..."); + // // TODO: send audio to crimata BE + // // ws.send(audio); + // } + // } + // } + // }); + // } + }) win.on("closed", () => { win = null; diff --git a/src/components/UI/UIDetails/inputItem.vue b/src/components/UI/UIDetails/inputItem.vue index f4e2f36..7e69a15 100644 --- a/src/components/UI/UIDetails/inputItem.vue +++ b/src/components/UI/UIDetails/inputItem.vue @@ -11,31 +11,36 @@