Agora Integration
This guide shows how to combine an Agora Voice Chat with the atmoky WebSDK to spatialize the audio streams of the remote participants. Make sure you've read Basic Setup which explains the functions which will be called down below.
Integration
The following code adjusts the example implementation from the Start a Voice Call (Web SDK 4.x) guide in order to retrieve the MediaStreamTrack
from the remote participants media stream.
import AgoraRTC, { IAgoraRTCClient } from "agora-rtc-sdk-ng";// ... //let client: IAgoraRTCClient;// adjusted code from agora documentationtype MediaType = "audio" | "video";async function startBasicCall() { client = AgoraRTC.createClient({ mode: "rtc", codec: "vp8" }); client.on( "user-published", async (user: IAgoraRTCRemoteUser, mediaType: MediaType) => { // Subscribe to the remote user when the SDK triggers the "user-published" event await client.subscribe(user, mediaType); console.log("subscribe success"); // If the remote user publishes an audio track. if (mediaType === "audio") { const remoteAudioTrack = user.audioTrack as IRemoteAudioTrack; addParticipantSource(user.uid, removeAudioTrack.getMediaStreamTrack()); // we don't call the following as the audio would bypass the renderer // ~~~remoteAudioTrack.play();~~~ } client.on("user-unpublished", (user: any) => { console.log("user-unpublished"); client.unsubscribe(user); removeParticipantSource(user.uid); }); } );}