Audio playback from a file

I have a web app built with React using videosdk. The core function is for a single human user to join the session and record their audio in response to some audio prompts. I want these programmatically run audio prompts to be in the cloud recording too, so is there a way to programmatically run audio from an audio file within the videosdk session?

getAudioMediaPlaybackController seems to hint at something like this but I can’t quite figure it out.

Appreciate if somebody can help me out with this.

Hey @omar

Thanks for your feedback.

Video SDK supports using a media file(mp3, mp4,wav, etc.) as the audio input. You can invoke it as follows:

const stream = client.getMediaStream();
await stream.startAudio({ mediaFile: { url: mediaPlaybackUrl, loop: true } });
const audioPlaybackController = stream.getAudioMediaPlaybackController();

//Pause the audio
await audioPlaybackController.pause();
//Resume the audio
await audioPlaybackController.play();

Thanks
Vic

1 Like

TypeError: stream.startAudio is not a function

I’m getting this error. Any idea why this would be happening?