From a48e5d07142f27207c081afb10e89a603c183540 Mon Sep 17 00:00:00 2001 From: Filipi Fuchter Date: Thu, 30 Jan 2025 10:14:37 -0300 Subject: [PATCH] Only sending the message when it is a remote audio track. --- .../client/react-native/src/App.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/examples/bot-ready-signalling/client/react-native/src/App.js b/examples/bot-ready-signalling/client/react-native/src/App.js index 5b9e439f9..2d07eca1e 100644 --- a/examples/bot-ready-signalling/client/react-native/src/App.js +++ b/examples/bot-ready-signalling/client/react-native/src/App.js @@ -36,13 +36,16 @@ const CallScreen = () => { log(`Failed to disconnect ${err}`); }) }); + // Trigger so the bot can start sending audio + callObject.on("track-started", (evt) => { + if (evt.track.kind === "audio" && evt.participant.local === false) { + handleEventToConsole(evt) + log("Sending the message that will trigger the bot to play the audio.") + callObject.sendAppMessage("playable") + } + }); callObject.on("error", (evt) => log(`Error: ${evt.error}`)); // Other events just for awareness - callObject.on("track-started", (evt) => { - handleEventToConsole(evt) - log("Will send the audio message to play the audio at the next tick") - callObject.sendAppMessage("playable") - }); callObject.on("track-stopped", handleEventToConsole); callObject.on("participant-joined", handleEventToConsole); callObject.on("participant-updated", handleEventToConsole);