Table of Contents

Switch Source Media Devices of Published Stream

A user may want to switch to alternate Media Devices for his published stream. EnableX API allows Media Device switching on the fly.

The window.EnxRtc.switchMediaDevice() method allows you to switch Microphone, Bluetooth devices, or speakers. You can use window.EnxRtc.getDevices() method to fetch a list of all audio devices and use one of the audio device names to make the switch.

Method: switchMediaDevice(Device)


  • @param {String} device – The device name as received from getDevices() API

Event Listeners:

  • onNotifyDeviceUpdate – When the Audio Device change is complete.


Switched Audio Device name

// deviceName is received from getDevice api
window.EnxRtc.switchMediaDevice(deviceName, function (data) {
}, function (err) {
console.log('Uh oh… error resizeLocalView ' + JSON.stringify(err));
// To listen event listener

Switch between Rear & Front Camera

If the user looks to switch between Rear and Front Camera as a source for published Stream, use window.EnxRtc.switchCamera() method.

Method: switchCamera() – No parameter needed

window.EnxRtc.switchCamera(false, function (data) {
}, function (err) {console.log(JSON.stringify(err));