Why can I change volume level on a webRTC call using the native control bar but not programatically?

StackOverflow https://stackoverflow.com/questions/20055634

  •  31-07-2022
  •  | 
  •  

Question

Reading this question looks like it's not possible to change volume levels to webRTC streams. Even exploring the audio stream object with dev tools, there is no volume property.

MediaStreamTrack {onended: null, onunmute: null, onmute: null, readyState: "live", enabled: true…}
enabled: true
id: "B3o0SZOXfI9PJjesCKxvFW0Gn3J6sYWxebvSa0"
kind: "audio"
label: "Default"
onended: null
onmute: null
onunmute: null
readyState: "live"
__proto__: MediaStreamTrack

Although the embedded controls of the video element, are able to change the volume levels (just to be sure, I checked and they are not changing the system level volume)

So how is it possible to change the volume levels using the controls but not programmatically?.

Does anybody know where these controls are pointing?.

Was it helpful?

Solution

It is possible to change the volume programmatically using jquery or javascript.

jquery was causing me confusion as I was trying to do

$("#videoid").volume 

getting undefined as result, but the way to do it with jquery is

$("#videoid").prop("volume",0.5)

or with plain javascript

document.getElementById("videoid").volume=0.5;

With this we can change the volume during a live webrtc communication.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top