Stream Management
This page covers everything related to media streams in a Cordova session: controlling the local camera and microphone, updating stream configuration, handling remote streams, managing active talkers, and configuring video views and quality.
Switch Audio / Microphone Device
switchMediaDevice() switches the active microphone or Bluetooth audio device for the
published stream without interrupting the session. Use getDevices() first to retrieve
the available device list, then pass one of the returned device names to this method.
- Method:
window.EnxRtc.switchMediaDevice(deviceName, successCallback, errorCallback) - Parameter:
deviceName— String. Device name as returned bygetDevices() - Event:
onNotifyDeviceUpdate— fired when the switch is complete
// deviceName comes from window.EnxRtc.getDevices()
window.EnxRtc.switchMediaDevice(
deviceName,
function(data) { console.log("Device switched:", JSON.stringify(data.data)); },
function(err) { console.error("Switch failed:", JSON.stringify(err)); }
);
window.EnxRtc.addEventListner("onNotifyDeviceUpdate", function(data) {
console.log("Active device updated:", JSON.stringify(data.data));
});
Switch Front / Rear Camera
switchCamera() toggles between the front-facing and rear-facing camera. The switch takes
effect on the live published stream immediately.
- Method:
window.EnxRtc.switchCamera()
window.EnxRtc.switchCamera(
false,
function(data) { console.log("Camera switched:", JSON.stringify(data.data)); },
function(err) { console.error("Camera switch failed:", JSON.stringify(err)); }
);
Mute / Unmute Your Microphone
muteSelfAudio() mutes or unmutes the local audio track. When you toggle audio:
- You receive
onAudioEventconfirming your own state change - All other participants receive
onRemoteStreamAudioMuteoronRemoteStreamAudioUnMuteso they can update their UI
- Method:
window.EnxRtc.muteSelfAudio(audio) - Parameter:
audio— Boolean.trueto mute,falseto unmute
// Mute microphone
window.EnxRtc.muteSelfAudio(true);
// Unmute microphone
window.EnxRtc.muteSelfAudio(false);
// Self: confirmed mute/unmute state
window.EnxRtc.addEventListner("onAudioEvent", function(data) {
console.log("Audio state:", JSON.stringify(data.data));
});
// Others: a participant muted their audio
window.EnxRtc.addEventListner("onRemoteStreamAudioMute", function(data) {
console.log("Remote audio muted:", JSON.stringify(data.data));
});
// Others: a participant unmuted their audio
window.EnxRtc.addEventListner("onRemoteStreamAudioUnMute", function(data) {
console.log("Remote audio unmuted:", JSON.stringify(data.data));
});
Mute / Unmute Your Camera
muteSelfVideo() mutes or unmutes the local video track. Similar to audio, your own
state change is confirmed via onVideoEvent and all other participants are notified via
onRemoteStreamVideoMute or onRemoteStreamVideoUnMute.
- Method:
window.EnxRtc.muteSelfVideo(video) - Parameter:
video— Boolean.trueto mute,falseto unmute
// Mute camera
window.EnxRtc.muteSelfVideo(true);
// Unmute camera
window.EnxRtc.muteSelfVideo(false);
// Self: confirmed state
window.EnxRtc.addEventListner("onVideoEvent", function(data) {
console.log("Video state:", JSON.stringify(data.data));
});
// Others: a participant muted their camera
window.EnxRtc.addEventListner("onRemoteStreamVideoMute", function(data) {
console.log("Remote video muted:", JSON.stringify(data.data));
});
// Others: a participant unmuted their camera
window.EnxRtc.addEventListner("onRemoteStreamVideoUnMute", function(data) {
console.log("Remote video unmuted:", JSON.stringify(data.data));
});
Update Stream Configuration
updateConfiguration() lets you modify bandwidth parameters for a live stream without
restarting it. Both local and remote streams support this method.
- Method:
window.EnxRtc.updateConfiguration(configurationOptions, successCallback, errorCallback)
var videoQualityOptions = {
maxVideoBW: "900",
minVideoBW: "150",
maxAudioBW: "150",
minAudioBW: "150"
};
window.EnxRtc.updateConfiguration(
videoQualityOptions,
function(data) { console.log("Config updated:", JSON.stringify(data.data)); },
function(err) { console.error("Config update failed:", JSON.stringify(err)); }
);
Mute / Unmute Subscribed Stream Audio
muteSubscribeStreamsAudio() lets you silence all incoming remote audio streams at your
own endpoint without affecting what others hear. This is a local-only operation — other
participants are not notified.
- Method:
window.EnxRtc.muteSubscribeStreamsAudio(mute, successCallback, errorCallback) - Parameter:
mute— Boolean.trueto mute all incoming audio,falseto unmute
// Silence all incoming audio
window.EnxRtc.muteSubscribeStreamsAudio(
true,
function(data) { console.log("Subscribed audio muted:", JSON.stringify(data.data)); },
function(err) { console.error("Error:", JSON.stringify(err)); }
);
// Restore incoming audio
window.EnxRtc.muteSubscribeStreamsAudio(
false,
function(data) { console.log("Subscribed audio unmuted:", JSON.stringify(data.data)); },
function(err) { console.error("Error:", JSON.stringify(err)); }
);
The Active Talker feature determines how many remote video streams your endpoint receives at any given time. The EnableX server continuously tracks who is speaking and sends the most active participants' streams to each endpoint.
Get the Maximum Talker Count
getMaxTalkers() returns the room-level maximum number of simultaneous active talker
streams. This is a room configuration limit set when the room was created.
- Method:
window.EnxRtc.getMaxTalkers() - Event:
onMaxTalkerCount— returns the maximum allowed talker count
window.EnxRtc.getMaxTalkers();
window.EnxRtc.addEventListner("onMaxTalkerCount", function(data) {
console.log("Max talkers allowed:", JSON.stringify(data.data));
});
Get the Current Talker Count
getTalkerCount() returns the number of active talker streams currently being received at
this endpoint. This may be the default value set by the application or a custom value chosen by the
user.
- Method:
window.EnxRtc.getTalkerCount() - Event:
onGetTalkerCount— returns the current talker count
window.EnxRtc.getTalkerCount();
window.EnxRtc.addEventListner("onGetTalkerCount", function(data) {
console.log("Current talker count:", JSON.stringify(data.data));
});
Set the Talker Count
setTalkerCount() controls how many remote video streams this endpoint receives. You can
embed this as an application-level setting or expose it as a UI control so users can choose how many
participants' videos they want to see.
- Method:
window.EnxRtc.setTalkerCount(numTalkers) - Parameter:
numTalkers— Number, range 0–6 - Event:
onSetTalkerCount— confirms the new count
numTalkers to 0 ensures the list never becomes empty — you
will still receive up to 3 audio-only streams. Setting it to 1–6 means you receive that
many video streams.
// Receive 4 active talker streams
window.EnxRtc.setTalkerCount(4);
window.EnxRtc.addEventListner("onSetTalkerCount", function(data) {
console.log("Talker count set:", JSON.stringify(data.data));
});
The Cordova SDK provides methods to hide/show individual views, resize them during a session, set the video quality you receive, and adjust the player layout after a screen rotation.
Hide or Unhide Views
Each view type — local camera, remote streams, screen share, and canvas — can be hidden or shown independently without stopping the underlying stream.
// Hide / show the local (self) view
window.EnxRtc.hideSelfView(true, function(data) {}, function(err) {}); // hide
window.EnxRtc.hideSelfView(false, function(data) {}, function(err) {}); // show
// Hide / show the remote view
window.EnxRtc.hideRemoteView(true, function(data) {}, function(err) {});
window.EnxRtc.hideRemoteView(false, function(data) {}, function(err) {});
// Hide / show the screen share view
window.EnxRtc.hideScreenShareView(true, function(data) {}, function(err) {});
window.EnxRtc.hideScreenShareView(false, function(data) {}, function(err) {});
// Hide / show the canvas view
window.EnxRtc.hideCanvasScreen(true, function(data) {}, function(err) {});
window.EnxRtc.hideCanvasScreen(false, function(data) {}, function(err) {});
Resize Views
resizeLocalView() and resizeRemoteView() adjust the dimensions and margins
of the respective views without reinitialising them.
var viewOptions = {
height: 130,
width: 100,
margin_top: 50,
margin_left: 0,
margin_right: 15,
margin_bottom: 10,
position: "top"
};
// Resize local view
window.EnxRtc.resizeLocalView(
viewOptions,
function(data) { console.log("Local view resized:", JSON.stringify(data.data)); },
function(err) { console.error("Error:", JSON.stringify(err)); }
);
// Resize remote view (adjust dimensions as needed)
viewOptions.height = 600;
viewOptions.width = 800;
viewOptions.position = "center";
window.EnxRtc.resizeRemoteView(
viewOptions,
function(data) { console.log("Remote view resized:", JSON.stringify(data.data)); },
function(err) { console.error("Error:", JSON.stringify(err)); }
);
Set and Get Video Quality
setReceiveVideoQuality() controls the quality of incoming video streams. Set it to
"Auto" to let EnableX choose the optimal quality based on available bandwidth, or pick
a fixed level: "HD", "SD", or "LD".
// Set desired incoming video quality
var videoQualityOptions = {
videoQuality: "Auto", // "HD" | "SD" | "LD" | "Auto"
streamType: "talker" // "talker" | "canvas"
};
window.EnxRtc.setReceiveVideoQuality(
videoQualityOptions,
function(data) { console.log("Quality set:", JSON.stringify(data.data)); },
function(err) { console.error("Error:", JSON.stringify(err)); }
);
// Get the currently active video quality
window.EnxRtc.getReceiveVideoQuality(
"talker",
function(data) { console.log("Current quality:", JSON.stringify(data.data)); },
function(err) { console.error("Error:", JSON.stringify(err)); }
);
Adjust Player Layout
Call adjustLayout() after a screen orientation change to re-fit the video player into
its parent container. This prevents letterboxing or clipping when the device rotates.
- Method:
window.EnxRtc.adjustLayout(successCallback, errorCallback)
window.EnxRtc.adjustLayout(
function(data) { console.log("Layout adjusted:", JSON.stringify(data.data)); },
function(err) { console.error("Error:", JSON.stringify(err)); }
);