Hi,
Thanks for the great service.
I use openvidu-browser-2.15.0.js API,
and I want to subscribeToAudio(true/false) when “streamCreated” event is fared.
But this error is thrown
Uncaught TypeError: Cannot read property ‘getAudioTracks’ of undefined
if it’s not possible to “subscribeToAudio” in “streamCreated” event listener, maybe you can suggest another solution for that.
for example by setting zero of subscriber audio volume.
I also didn’t find how can I change audio volume also (i asked here but no one responded after a few days my question was deleted).
The “subscribe” function has a “completionHandler” callback function, but this will not help either, since the “MediaStream” will be “undefined” and You will be get same error (Cannot read property ‘getAudioTracks’ of undefined)
You need to set SubscriberProperties (subscribeToAudio = true / false) when you subscribe to a stream.
I don’t know what you are trying to achieve. But, if you want to subscribe, you can listen to streamCreated
event and call subscribe()
to subscribe the stream.
When a user receives streamCreated
event, it doesn’t mean the user is subscribed to the stream. That event is just letting users know that they can subscribe to that stream if they want. You can subscribe to audio/video on Session.subscribe
method by using SubscriberProperties.
And after the user is subscribed, it can dynamically enable/disable audio/video stream from the Subscriber object.