I went through the publisher docs which has the methods publishVideo(value)
and publishAudio(value)
.
Corresponding to the video part, the subscriber receives the event videoDisabled
or videoEnabled
with the reason publishVideo
which allows me to determine whether the subscribed participant has intentionally turned off their video or not, but I can't find something similar for audio such as audioDisabled
or audioEnabled
. audioBlocked
event supposedly only covers blocks by browser's autoplay policy: Dispatched when the subscriber's audio is blocked because of the browser's autoplay policy
.
The audioLevelUpdated
event provides the current audio level, but that could just be silence, not an intentional mute, so that doesn't look ideal for this purpose.
I want to show a audio muted icon on the subscribed participants element when they have intentionally turned off their audio by calling publishAudio()
method. How can that be achieved?
Referenced docs:
Subscriber events: https://tokbox.com/developer/sdks/js/reference/Subscriber.html#events
Publisher methods: https://tokbox.com/developer/sdks/js/reference/Publisher.html#methods
Each stream has an hasAudio
attribute that returns false if the user's audio is muted or their microphone is muted. Similarly, streams also have a hasVideo
attribute. You can reference the stream docs at https://tokbox.com/developer/sdks/js/reference/Stream.html.
I personally use it like so:
session.streams.forEach((stream) => {
const name = stream.name;
const video = stream.hasVideo;
const audio = stream.hasAudio;
});
You can listen for these changes with the session.on('streamPropertyChanged')
event: https://tokbox.com/developer/sdks/js/reference/StreamPropertyChangedEvent.html