<template>
<div id=inputItem
- class="input-item playing"
+ class="input-item"
+ :class="{ playing: isRecording }"
:style="{ top: `${elementY}px`, left: `${elementX}px` }">
<span class="play"></span>
<span class="pause"></span>
<script lang="ts">
-import { defineComponent } from "vue";
+import { defineComponent, onMounted, onUnmounted, ref } from "vue";
import draggify from '@/modules/draggify';
+import useMitt from "@/modules/mitt";
export default defineComponent({
name: "InputItem",
setup() {
- const { elementX, elementY } = draggify({ elementId: 'inputItem'})
+ const isRecording = ref(false);
+
+ const { emitter } = useMitt();
+ const { elementX, elementY } = draggify({ elementId: 'inputItem'});
+
+ onMounted(() => {
+ emitter.on('input-audio-record', (record) => isRecording.value = record);
+ })
+
+ onUnmounted(() => {
+ emitter.all.clear();
+ })
return {
elementX,
- elementY
+ elementY,
+ isRecording
}
}
if (input) post('message', message);
}
+ function recordStream(record: boolean) {
+ // tell ipcMain to pause or resume stream recording.
+ post('update-recorder', record);
+ // toggle inputItem audio animation.
+ emitter.emit('input-audio-record', record);
+ }
+
const {
visualizeStreamAsPaths,
expandBubble
function keyupHandler(e: any) {
if (e.key === " " && visualizeStream.value) {
- post('update-recorder', false);
+ recordStream(false)
visualizeStream.value = false;
paths.value = []
audioBubbleWidth.value = 10;
}
if (input === " " && visualizeStream.value === false) {
visualizeStream.value = true;
- post('update-recorder', true);
+ recordStream(true)
expandBubble(audioBubbleWidth);
visualizeStreamAsPaths(stream, paths, audioBubbleWidth);
return;