Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MediaTrack detect highest level

I have several audio tracks, which i got from getUserMedia (microphone). Those are being transmitted via WebRTC. I want to highlight the stream that is active at the moment, but checking the documentation for MediaTrack i cannot find any method to access something that allows me to determine if that object is the most active at the moment.

So, if there is a method to get the current output, with some filter i should be able to determine which one is the "most active" one and highlight it.

Does such method exist in the API? Is there another approach that i can take for that?

like image 881
cdvv7788 Avatar asked Oct 23 '25 12:10

cdvv7788


1 Answers

MediaStream Object has APIs refer to detect active stream but not its MediaStreamTrack.

Even if you want to detect active speaker via volume level you need to pass MediaStream to Web audio API - AudioContext to analyse it. example

If you have proper RTCPeerConnection then you can use getStats API. example

like image 140
Sasi Varunan Avatar answered Oct 26 '25 01:10

Sasi Varunan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!