{"id":4775,"date":"2021-12-07T19:44:52","date_gmt":"2021-12-07T11:44:52","guid":{"rendered":"https:\/\/www.enablex.io\/developer\/?page_id=4775"},"modified":"2025-02-22T20:54:27","modified_gmt":"2025-02-22T12:54:27","slug":"switch-camera-mic-speaker","status":"publish","type":"page","link":"https:\/\/doc.smartflomeet.ttns.in\/developer\/video-api\/client-api\/cordova-toolkit\/switch-camera-mic-speaker\/","title":{"rendered":"Switch Camera, Microphone &#038; Speaker: Cordova\/Ionic SDK &#8211; Video API"},"content":{"rendered":"\n<h4>Table of Contents<\/h4>\n\n\n\n<ul><li><a href=\"#switch-media-devices\">Switch Source Media Devices of Published Stream<\/a><\/li><li><a href=\"#switch-camera\">Switch between Rear &amp; Front Camera<\/a><\/li><\/ul>\n\n\n\n<a name=\"switch-media-devices\"><\/a>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2>Switch Source Media Devices of Published Stream<\/h2>\n\n\n\n<p>A user may want to switch to alternate Media Devices for his published stream. Video API allows Media Device switching on the fly.  <\/p>\n\n\n\n<p>The <code>window.EnxRtc.switchMediaDevice()<\/code> method allows you to switch Microphone, Bluetooth devices, or speakers. You can use <code>window.EnxRtc.getDevices() <\/code>method to fetch a list of all audio devices and use one of the audio device names to make the switch.<\/p>\n\n\n\n<p><strong>Method<\/strong>: <code>switchMediaDevice(Device)<\/code><\/p>\n\n\n\n<p><strong>Parameters: <\/strong><\/p>\n\n\n\n<ul><li><code>@param {String} device<\/code> \u2013  The device name as received from <code>getDevices()<\/code> API<\/li><\/ul>\n\n\n\n<p><strong>Event Listeners:<\/strong><\/p>\n\n\n\n<ul><li><code>onNotifyDeviceUpdate<\/code> \u2013 When the Audio Device change is complete. <\/li><\/ul>\n\n\n\n<p><strong>Returns:<\/strong><\/p>\n\n\n\n<p>Switched Audio Device name<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ deviceName is received from getDevice api\nwindow.EnxRtc.switchMediaDevice(deviceName, function (data) {\nconsole.log(JSON.stringify(data.data));\n}, function (err) {\nconsole.log('Uh oh\u2026 error resizeLocalView ' + JSON.stringify(err));\n});\n\/\/ To listen event listener\nwindow.EnxRtc.addEventListner(\"onNotifyDeviceUpdate\",\n(data)\nfunction\n{\nconsole.log(JSON.stringify(data.data));\n});<\/pre>\n\n\n\n<a name=\"switch-camera\"><\/a>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3>Switch between Rear &amp; Front Camera<\/h3>\n\n\n\n<p>If the user looks to switch between Rear and Front Camera as a source for published Stream, use <code>window.EnxRtc.switchCamera()<\/code> method. <\/p>\n\n\n\n<p> <strong>Method: <\/strong><code>switchCamera() \u2013 <\/code>No parameter needed<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">window.EnxRtc.switchCamera(false, function (data) {\nconsole.log(JSON.stringify(data.data));\n}, function (err) {console.log(JSON.stringify(err));\n});<\/pre>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator is-style-wide\"\/>\n\n\n\n<div class=\"wp-block-columns\">\n<div class=\"wp-block-column\">\n<p>\u2190 <a href=\"..\/room-connection\/\"><\/a><a href=\"..\/room-connection\/\">Room Connection<\/a><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column\">\n<p class=\"has-text-align-center\"><a href=\"..\/\">Index<\/a><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column\">\n<p class=\"has-text-align-right\"><a href=\"..\/mute-audio-video-stream\/\">Mute-Unmute Audio Video<\/a> \u2192<a href=\"\/developer\/how-to-use\/\"><\/a><\/p>\n<\/div>\n<\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Table of Contents Switch Source Media Devices of Published Stream Switch between Rear &amp; Front Camera Switch Source Media Devices of Published Stream A user may want to switch to alternate Media Devices for his published stream. Video 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&hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"parent":3719,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"ub_ctt_via":""},"featured_image_src":null,"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"featured":false,"featured-large":false},"uagb_author_info":{"display_name":"vcxdevwpadmin","author_link":"https:\/\/doc.smartflomeet.ttns.in\/developer\/author\/vcxdevwpadmin\/"},"uagb_comment_info":0,"uagb_excerpt":"Table of Contents Switch Source Media Devices of Published Stream Switch between Rear &amp; Front Camera Switch Source Media Devices of Published Stream A user may want to switch to alternate Media Devices for his published stream. Video API allows Media Device switching on the fly. The window.EnxRtc.switchMediaDevice() method allows you to switch Microphone, Bluetooth&hellip;","_links":{"self":[{"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/pages\/4775"}],"collection":[{"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/comments?post=4775"}],"version-history":[{"count":0,"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/pages\/4775\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/pages\/3719"}],"wp:attachment":[{"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/media?parent=4775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}