How to get AudioContext from WebRTCPeer or Subscriber

Nice to meet you.
I am a junior developer who is successfully performing real-time video interview service using OpenVidu.

During development, I am trying to visualize audio by receiving audio from a remote stream rather than a local stream.

I thought it wouldn’t be difficult at all to visualize this, since I’m already listening to other users, but it doesn’t seem to be. I seem to be missing something.
Hints from other great developers for visualizing audio seem to all use AudioContext, but I’m not sure how to incorporate it into Openvidu.

Even if I check the objects one by one using the browser’s developer tool, I can’t figure out how to combine them.

I’d like to get some advice on whether my approach is the right way, or if there is another way.

Here is the example code I was trying to graft.

Thank you.

Hi @buck , welcome to OpenVidu.

Have you tried the publisherStartSpeaking event? Speech detection - OpenVidu Docs

Also the AudioVolumeDetection event could help you.

Also, if all you need is a call to AudioContext.createMediaStreamSource(mediaStream), then you can simply access the internal MediaStream of any Stream object with Stream.getMediaStream()

@CSantosM
Of course!
Even now, we use detection and recording functions conveniently only when users speak!

@pabloFuente
I’m sorry for my lack of understanding.
I want to check and visualize the audio of other users except myself, but it’s not going well.
( visualizing my audio has already been completed.)
I’m going to apply it to the sauce below. Yes, that’s right. I need AudioContext.createMediaStreamSource(mediaStream) as the leader explained.
Am I missing something?

Stream.getMediaStream is a method. It is not a property:

stream.getMediaStream();

That will return the native Web API MediaStream object associated to OpenVidu’s Stream object.

@pabloFuente
As you said, I checked the value on the browser console, but I don’t know how to get it undefined.

Where and what am I missing and doing wrong?

Why are you accessing it on videoElementCreated event?
Use method Session.subscribeAsync to get your Subscriber object. Once that promise is resolved, you may access the internal Stream.getMediaStream() object and that should be properly defined.