diff --git a/client/src/components/AudioOutput.jsx b/client/src/components/AudioOutput.jsx
index ec77cec..6180d4d 100644
--- a/client/src/components/AudioOutput.jsx
+++ b/client/src/components/AudioOutput.jsx
@@ -1,10 +1,14 @@
import React, { useEffect, useRef } from "react";
-function AudioOutput({ currentAudioMessage, onFinishedPlaying }) {
+function AudioOutput({ currentAudioMessage, onFinishedPlaying, stopAudio }) {
const audioRef = useRef(null);
const urlRef = useRef(null);
const checkPlaybackIntervalRef = useRef(null);
+ useEffect(() => {
+ audioRef.current && audioRef.current.pause();
+ }, [stopAudio]);
+
useEffect(() => {
// Initialize the audio element if it does not exist
if (!audioRef.current) {
diff --git a/client/src/components/ConversationControls.jsx b/client/src/components/ConversationControls.jsx
index 1d157d3..3b73c00 100644
--- a/client/src/components/ConversationControls.jsx
+++ b/client/src/components/ConversationControls.jsx
@@ -6,11 +6,14 @@ function ConversationControls({
onSkipForward,
onRaiseHandOrNevermind,
isRaisedHand,
+ humanInterjection,
}) {
return (
-
-
+ {/* */}
+ {!humanInterjection && (
+
+ )}
diff --git a/client/src/components/Council.jsx b/client/src/components/Council.jsx
index 980dbbf..8b0fb1f 100644
--- a/client/src/components/Council.jsx
+++ b/client/src/components/Council.jsx
@@ -18,6 +18,8 @@ function Council({ options }) {
const [audioMessages, setAudioMessages] = useState([]); // To store multiple ArrayBuffers
const [isReady, setIsReady] = useState(false);
const [isRaisedHand, setIsRaisedHand] = useState(false);
+ const [humanInterjection, setHumanInterjection] = useState(false);
+ const [skipForward, setSkipForward] = useState(false);
const socketRef = useRef(null); // Using useRef to persist socket instance
@@ -71,11 +73,18 @@ function Council({ options }) {
setIsReady(true);
}
+ function handleOnSkipForward() {
+ setSkipForward(!skipForward);
+ }
+
function handleOnRaiseHandOrNevermind() {
- console.log("Setting isRaisedHand...");
setIsRaisedHand((prev) => !prev);
}
+ function handleOnHumanInterjection(value) {
+ setHumanInterjection(value);
+ }
+
function displayResetWarning() {
setActiveOverlay("reset");
}
@@ -96,17 +105,23 @@ function Council({ options }) {
className="text-container"
style={{ justifyContent: "end" }}
>
+ {humanInterjection && }
{isReady && (
)}
diff --git a/client/src/components/HumanInput.jsx b/client/src/components/HumanInput.jsx
index 4763592..cb4012c 100644
--- a/client/src/components/HumanInput.jsx
+++ b/client/src/components/HumanInput.jsx
@@ -2,11 +2,10 @@ import React from "react";
function HumanInput() {
return (
-
+
);
diff --git a/client/src/components/Output.jsx b/client/src/components/Output.jsx
index caac28b..696db49 100644
--- a/client/src/components/Output.jsx
+++ b/client/src/components/Output.jsx
@@ -8,17 +8,29 @@ function Output({
isActiveOverlay,
isRaisedHand,
onIsReady,
+ onHumanInterjection,
+ humanInterjection,
+ skipForward,
}) {
const [currentMessageIndex, setCurrentMessageIndex] = useState(0);
const [currentTextMessage, setCurrentTextMessage] = useState(null);
const [currentAudioMessage, setCurrentAudioMessage] = useState(null);
+ const [stopAudio, setStopAudio] = useState(false);
- // useEffect for raising hand or nevermind when a food is talking
+ useEffect(() => {
+ if (currentTextMessage && currentAudioMessage) {
+ console.log("Skipping forward");
+ proceedToNextMessage();
+ }
+ }, [skipForward]);
+
+ // useEffect for checking for raised hand when changing message index (inbetween food talking)
useEffect(() => {
if (!isRaisedHand) {
tryFindTextAndAudio();
} else {
- console.log("Human interjection time!");
+ setStopAudio(!stopAudio);
+ onHumanInterjection(true);
}
}, [currentMessageIndex]);
@@ -29,6 +41,7 @@ function Output({
currentTextMessage === null &&
currentAudioMessage === null
) {
+ onHumanInterjection(false);
tryFindTextAndAudio();
}
}, [isRaisedHand]);
@@ -37,10 +50,6 @@ function Output({
tryFindTextAndAudio();
}, [textMessages, audioMessages]);
- useEffect(() => {
- console.log("Hand raised: ", isRaisedHand);
- }, [isRaisedHand]);
-
function tryFindTextAndAudio() {
const textMessage = textMessages[currentMessageIndex];
const audioMessage = audioMessages.find(
@@ -62,21 +71,28 @@ function Output({
}
}
- function handleOnFinishedPlaying() {
+ function proceedToNextMessage() {
setCurrentTextMessage((prev) => null);
setCurrentAudioMessage((prev) => null);
setCurrentMessageIndex((prev) => prev + 1);
}
+ function handleOnFinishedPlaying() {
+ proceedToNextMessage();
+ }
+
return (
<>
-
+ {!humanInterjection && (
+
+ )}
>
);