In case you need to mute Audio or turn off video of your own published Media Stream, you may use APIs to do so. Similary, using API Call, you can unmute Audio or turn on Video on Media Stream again.
Table of Contents
Mute / Unmute Audio in a Stream
The EnxStream.muteAudio()
and EnxStream.unmuteAudio()
methods allow you to mute and unmute the audio track of a Local Stream.
Methods:
- To mute Audio track of Local Stream:
EnxStream.muteAudio()
– No Parameter required.
- To unmute Audio track of Local Stream:
EnxStream.unmuteAudio()
– No Parameter required.
Event Notifications:
-
user-audio-muted
– Notification to everyone in the Room when a user mutes self Audio. -
user-audio-unmuted
– Notification to everyone in the Room when a user unmutes self Audio.
localStream.muteAudio( function(res) { // Audio muted. Handle UI here }); localStream.unmuteAudio( function(res) { // Audio unmuted. Handle UI here }); // Notification to others when a user muted audio room.addEventListener("user-audio-muted", function (event) { // Handle UI here }); // Notification to others when a user muted audio room.addEventListener("user-audio-unmuted", function (event) { // Handle UI here });
Error Codes / Exceptions
Code | Description |
---|---|
1140 | Repeated API call made while a previous mute request is in process. |
1176 | The right to control media devices by the Moderator. |
1191 | Stream Track has ended. User must rejoin to restore Audio. |
Mute / Unmute Video in a Stream
The EnxStream.muteVideo()
and EnxStream.unmuteVideo()
methods allow you to mute and unmute the video track of a Local Stream.
Methods:
- Notification to everyone in the Room when a user mutes self Video.
EnxStream.muteVideo(Callback)
– No Parameter required.
- Notification to everyone in the Room when a user unmutes self Video.
EnxStream.unmuteVideo(Callback)
– No Parameter required.
Event Notifications:
-
user-video-muted
– Notification to everyone in the Room when a user mutes self Video. -
user-video-unmuted
– Notification to everyone in the Room when a user unmutes self Video.
localStream.muteVideo( function(res) { // Video muted. Handle UI here }); localStream.unmuteVideo( function(res) { // Video unmuted. Handle UI here }); // Notification to others when a user muted video room.addEventListener("user-video-muted", function (event) { // Handle UI here }); // Notification to others when a user muted video room.addEventListener("user-video-unmuted", function (event) { // Handle UI here });
Error Codes / Exceptions
Code | Description |
---|---|
1140 | Repeated method call made while a previous unmute request is in process. |
1176 | The right to control media devices by the Moderator. |