How to get microphone volume level

1,530 views
Skip to first unread message

Rishi Khandelwal

unread,
Jul 2, 2013, 6:36:35 AM7/2/13
to eas...@googlegroups.com
Hello

I want to get system's microphone volume level using easyrtc.

I found some description about getting volume level of system's microphone in webrtc apis
 code :
 var audioTracks = stream.getAudioTracks(); // returns MediaStream
 var info = audioTracks[0].states();   // Returns mediaStreamTracks
var volume = info.volume.

But when I am running this code with easyrtc , it says MediaStreamTrack does not have states() method.

Does easyRtc not support this or anything else ?

Please help me to solve this problem

Eric Davies

unread,
Jul 2, 2013, 12:53:14 PM7/2/13
to eas...@googlegroups.com
Hi Rishi,

The MediaStreamTrack you are getting from stream.getAudioTracks is a webrtc object, not an easyRTC object. If there is a property you are expecting to find in a MediaStreamTrack that isn't there, it isn't a  matter of easyRTC supporting, but your browser supporting it.

That said, I've never seen mention of the states method in the JavaScript API. I suspect the reference you found to a states() method was actually in the Native API that is used if you are trying to write a browser itself or a native client.

Typically, if you want to control the volume of an incoming media stream, you manipulate the volume property of a video object that is playing the media stream.

Eric.

Rishi Khandelwal

unread,
Jul 3, 2013, 1:18:28 AM7/3/13
to eas...@googlegroups.com
Hi Eric

I am trying this now :

1. var volume = stream.volume   // output = undefined

2. var volume = stream.getAudioTracks()[0].volume   // output = undefined

I am not getting properly that how should I get the volume..

I am stuck in this problem. Please suggest me the feasible solution.

Rishi

Eric Davies

unread,
Jul 3, 2013, 12:24:20 PM7/3/13
to eas...@googlegroups.com
Hi Rishi,

If you use the javascript debugger built into chrome to place a breakpoint in your code so you can examine an audio track, these are the only properties you'll see:
  1. enabledtrue
  2. id"6aY4kGI23VRtgDWjyKdbSG7C4gRKTKIdqvHAa0"
  3. kind"audio"
  4. label"Default"
  5. onendednull
  6. onmutenull
  7. onunmutenull
  8. readyState"live"

Note the conspicuous absence of a volume property.

Sounds like you want to control the sensitivity of the microphone. To the best of my knowledge, that isn't supported by WebRTC yet. You may be able to do something with the WebAudio api but I don't have any experience with it. Suggest you raise the question on the webrtc discussion group.

Eric.


Reply all
Reply to author
Forward
0 new messages