Developer Tools
This page covers the diagnostic and utility features of the Cordova SDK: live media statistics, audio-only mode, managing the app when it switches to the background, the proximity sensor, outbound PSTN/SIP dialing, screenshot capture, and log management.
enableStats() activates a real-time statistics overlay over each video player. This is
useful during development and QA to monitor stream health without any external tooling.
The following data is surfaced for each stream:
- Local stream: transmission bandwidth, video resolution
- Subscribed stream: receiving bandwidth, video resolution, available bandwidth for the remote user, packet loss
- Method:
window.EnxRtc.enableStats(isEnabled) - Parameter:
isEnabled— Boolean.trueto enable,falseto disable
| Event | Description |
|---|---|
onAcknowledgeStats | Confirms stats have been enabled or disabled |
onReceivedStats | Fires periodically with statistics for all streams |
onPlayerStats | Fires with statistics for a specific player's stream |
// Enable stats
window.EnxRtc.enableStats(true);
// Stats enabled/disabled confirmation
window.EnxRtc.addEventListner("onAcknowledgeStats", function(data) {
console.log("Stats toggle acknowledged:", JSON.stringify(data.data));
});
// Periodic stats for all streams
window.EnxRtc.addEventListner("onReceivedStats", function(data) {
console.log("Stream stats:", JSON.stringify(data.data));
renderStatsOverlay(data.data);
});
// Stats for a specific player
window.EnxRtc.addEventListner("onPlayerStats", function(data) {
console.log("Player stats:", JSON.stringify(data.data));
});
setAudioOnlyMode() switches the local endpoint to an audio-only experience. In this mode
your camera is not published and you do not receive any remote video. Screen sharing streams are not
affected — they can still be received in audio-only mode.
Call this method as a toggle: pass true to enter audio-only mode and false
to restore audio-video.
- Method:
window.EnxRtc.setAudioOnlyMode(audioOnly, successCallback, errorCallback) - Parameter:
audioOnly— Boolean.truefor audio-only,falsefor audio-video
// Switch to audio-only
window.EnxRtc.setAudioOnlyMode(
true,
function(data) { console.log("Audio-only mode ON:", JSON.stringify(data.data)); },
function(err) { console.error("Error:", JSON.stringify(err)); }
);
// Restore audio-video
window.EnxRtc.setAudioOnlyMode(
false,
function(data) { console.log("Audio-video restored:", JSON.stringify(data.data)); },
function(err) { console.error("Error:", JSON.stringify(err)); }
);
When a user switches to another app, the RTC session continues running in the background. You can control whether the local video track is paused and whether remote video streams continue to be received while the app is in the background — saving battery and bandwidth.
Switching to Background
Call stopVideoTracksOnApplicationBackground() when the app moves to the background. Pass
true for both parameters to pause all video, or selectively pause only local or remote.
- Method:
window.EnxRtc.stopVideoTracksOnApplicationBackground(localMuteState, remoteMuteState, successCallback, errorCallback)
| Parameter | Type | Description |
|---|---|---|
localMuteState | Boolean | true to pause local video publishing when backgrounded |
remoteMuteState | Boolean | true to stop receiving remote video when backgrounded |
// Pause both local and remote video on background
window.EnxRtc.stopVideoTracksOnApplicationBackground(
true,
true,
function(data) { console.log("Background: video paused:", JSON.stringify(data.data)); },
function(err) { console.error("Error:", JSON.stringify(err)); }
);
Returning to Foreground
Call startVideoTracksOnApplicationForeground() when the app returns to the foreground to
resume video tracks that were paused on background.
- Method:
window.EnxRtc.startVideoTracksOnApplicationForeground(localUnMuteState, remoteUnMuteState, successCallback, errorCallback)
// Resume both local and remote video on foreground
window.EnxRtc.startVideoTracksOnApplicationForeground(
true,
true,
function(data) { console.log("Foreground: video resumed:", JSON.stringify(data.data)); },
function(err) { console.error("Error:", JSON.stringify(err)); }
);
enableProximitySensor() activates the device's proximity sensor so that the screen can
be dimmed or locked when the user holds the device to their ear — useful for audio-call UX.
The proximity sensor reports NEAR or FAR based on a LUX threshold. When LUX is below the threshold (object is close), the sensor returns NEAR; above the threshold, it returns FAR.
- Method:
window.EnxRtc.enableProximitySensor(isEnabled, successCallback, errorCallback) - Parameter:
isEnabled— Boolean.trueto enable,falseto disable
window.EnxRtc.enableProximitySensor(
true,
function(data) { console.log("Proximity sensor enabled:", JSON.stringify(data.data)); },
function(err) { console.error("Error:", JSON.stringify(err)); }
);
The SDK supports dialing out to a phone number or SIP URI directly from within a video session. The called party hears a standard phone ring and, on answering, joins the session as an audio-only participant.
Dial Out
- Method:
window.EnxRtc.makeOutboundCall(dialout_number) - Parameter:
dialout_number— String. Phone number with country code (no leading "00" or "+") or a SIP URI
| Event | Description |
|---|---|
onOutBoundCallInitiated | Confirms the call has been initiated |
onDialStateEvents | Real-time dial state updates: initiated, calling, connecting, connected, terminated, failed, disconnected |
// Dial a PSTN number (country code without + or 00)
window.EnxRtc.makeOutboundCall("919876543210");
window.EnxRtc.addEventListner("onOutBoundCallInitiated", function(data) {
console.log("Call initiated:", JSON.stringify(data.data));
showCallingUI();
});
window.EnxRtc.addEventListner("onDialStateEvents", function(data) {
console.log("Dial state:", JSON.stringify(data.data));
// data.data.state: "calling" | "connected" | "terminated" | ...
updateCallStatusUI(data.data.state);
});
| Error Code | Description |
|---|---|
| 1141 | A dial-out request is already in progress |
| 1142 | CLI does not match the configured phone number |
Send DTMF Tones
If the dialed PSTN call connects to an IVR, use sendDTMF() to pass numeric digits through
the call. This method can be called multiple times to navigate IVR menus. The outbound call must be
in a connected state before sending DTMF.
- Method:
window.EnxRtc.sendDTMF(dialout_number, digit)
| Parameter | Type | Description |
|---|---|---|
dialout_number | String | The same number used in makeOutboundCall() |
digit | String | One or more DTMF digit(s) to send, e.g. "1" or "123" |
- Event:
onOutBoundCallSendDtmf— success or failure with error code
// Press "1" to navigate IVR menu
window.EnxRtc.sendDTMF("919876543210", "1");
window.EnxRtc.addEventListner("onOutBoundCallSendDtmf", function(data) {
console.log("DTMF result:", JSON.stringify(data.data));
});
captureScreenShot() takes a snapshot of any video stream (local or remote) and returns
the image as raw bitmap data. Pass the stream ID of the stream you want to capture.
- Method:
window.EnxRtc.captureScreenShot(streamId) - Parameter:
streamId— String. ID of the stream to capture - Event:
OnCapturedView— delivers the bitmap image data
// Capture a snapshot of a specific stream
window.EnxRtc.captureScreenShot(streamId);
window.EnxRtc.addEventListner("OnCapturedView", function(data) {
// data contains the raw bitmap image
var imageData = data.data;
saveOrDisplayImage(imageData);
});
The SDK writes diagnostic logs to the browser console during a session. You can control log verbosity and optionally upload logs to the EnableX team for support analysis.
Enable or Disable Logging
Log I/O is a non-trivial overhead. Disable logging in production to avoid performance impact and only enable it when debugging.
- Method:
window.EnxRtc.enableLogs(enable) - Parameter:
enable— Boolean.trueto enable logging,falseto disable
window.EnxRtc.enableLogs(true); // Enable logging
window.EnxRtc.enableLogs(false); // Disable logging
Share Logs with EnableX
postClientLogs() uploads the most recent 500 lines of console logs to EnableX via HTTP
POST for technical review. You must enable logging before calling this method.
- Method:
window.EnxRtc.postClientLogs() - Event:
onLogUploaded— fires when the upload completes
// Ensure logging is active first
window.EnxRtc.enableLogs(true);
// Upload logs to EnableX
window.EnxRtc.postClientLogs();
window.EnxRtc.addEventListner("onLogUploaded", function(data) {
console.log("Logs uploaded:", JSON.stringify(data.data));
showLogUploadConfirmation();
});