]> Repos - mime-chat/commitdiff
trigger inputItem audio animation on stream record
authorriqo <hernandeze2@xavier.edu>
Sat, 6 Mar 2021 20:31:11 +0000 (14:31 -0600)
committerriqo <hernandeze2@xavier.edu>
Sat, 6 Mar 2021 20:31:11 +0000 (14:31 -0600)
src/components/inputItem.vue
src/components/taInput/inputController.ts

index 13c7303ad2447a126db368fb440a0db30f04175b..6a303c269d08101f9614847d206848f09894b0e1 100644 (file)
@@ -1,6 +1,7 @@
 <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
     }
   }
 
index 1f8df0ba02030c0b450e438f6c3ab12c88c7b420..e1d1ce98baa21886546d270d5a643310f5f1dd06 100644 (file)
@@ -37,6 +37,13 @@ export default function useInputController() {
         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
@@ -54,7 +61,7 @@ export default function useInputController() {
     function keyupHandler(e: any) {
         if (e.key === " " && visualizeStream.value) {
 
-            post('update-recorder', false);
+            recordStream(false)
             visualizeStream.value = false;
             paths.value = []
             audioBubbleWidth.value = 10;
@@ -84,7 +91,7 @@ export default function useInputController() {
         }
         if (input === " " && visualizeStream.value === false) {
             visualizeStream.value = true;
-            post('update-recorder', true);
+            recordStream(true)
             expandBubble(audioBubbleWidth);
             visualizeStreamAsPaths(stream, paths, audioBubbleWidth);
             return;