{"id":4076,"date":"2021-11-08T14:11:40","date_gmt":"2021-11-08T06:11:40","guid":{"rendered":"https:\/\/www.enablex.io\/developer\/?page_id=4076"},"modified":"2025-04-05T01:18:56","modified_gmt":"2025-04-04T17:18:56","slug":"get-devices","status":"publish","type":"page","link":"https:\/\/doc.smartflomeet.ttns.in\/developer\/video-api\/client-api\/web-toolkit\/get-devices\/","title":{"rendered":"Get Media Devices \u2013 Microphone, Camera and Speaker Access: Web SDK \u2013 Video API"},"content":{"rendered":"\n<blockquote class=\"wp-block-quote\"><p>This MediaStream API provides a way to access device cameras and microphones which may be used to create Media Stream to publish into Video Room.  It also exposes information about devices able to capture and render media.<\/p><\/blockquote>\n\n\n\n<p>You can initiate a Stream&nbsp;using&nbsp;either the browser\u2019s default Audio Device or&nbsp;by&nbsp;specifying&nbsp;the ID of&nbsp;the Audio Device connected to the device running the client application which requires you to get the Device IDs of all the connected devices. &nbsp;<\/p>\n\n\n\n<p>The&nbsp;<code>EnxRoom.getDevices()<\/code>&nbsp;method provides a list of all the Microphones connected to your Device.  On the method call, the browser prompts the user to grant access to the application for one or both the devices (as applicable). The user must allow access for successful initiation of the stream.&nbsp;If allowed access, <code>media-access-allowed<\/code> event is the end point and the method returns list of devices.  <\/p>\n\n\n\n<p>If user doesn&#8217;t allow access, <code>media-access-denied<\/code> event is received at the end point and the method returns error code 1144.<\/p>\n\n\n\n<p><strong>Method<\/strong>: <code>EnxRtc.getDevices(Callback)<\/code><\/p>\n\n\n\n<p><strong>Event Listeners:<\/strong><\/p>\n\n\n\n<ul><li><code>media-access-allowed<\/code> &#8211; When&nbsp;the&nbsp;user grants permission to the application to access the media devices.&nbsp;<\/li><li><code>media-access-denied<\/code> &#8211; When&nbsp;the&nbsp;user denies permission to the application to access the media devices.&nbsp;<\/li><\/ul>\n\n\n\n<p><strong>Returns:<\/strong> List of Devices<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">EnxRtc.getDevices( function(response) { \n     if( response.result === 0 ) {   \/\/ success                     \n         \/* Device Lists in response.devices *\/ \n         var camList =  response.devices.cam; \n         var micList =  response.devices.mic; \n\t var speakerList = response.devices.speaker;\n     }\n     else if(response.result === 1144){ \/\/ Error case  \n       \n     }\n});\n\nstream.addEventListner('media-access-allowed', function (response) {\n\t\/* response = {\n\t\tstream: StreamObject,\n\t\ttype: \"media-access-allowed\"\n\t}*\/\n});\n\nstream.addEventListner('media-access-denied', function (response) {\n\t\/* response = { type: 'media-access-denied', msg: err }*\/\n});<\/pre>\n\n\n\n<p><strong>Response JSON<\/strong> (With list of devices):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{\n     \"result\": 0,       \n     \"devices\": { \n             \"cam\":[ \n                 { \n                 \"deviceId\": \"\", \n                 \"groupId\": \"\", \n                 \"label\": \"\" , \n                 \"kind\" : \"\" \n                 } \n             ], \n             \"mic\": [ \n                 { \n                 \"deviceId\": \"\", \n                 \"groupId\": \"\", \n                 \"label\": \"\" , \n                 \"kind\" : \"\" \n                 } \n             ],\n\t     \"speaker\": [ \n                 { \n                 \"deviceId\": \"\", \n                 \"groupId\": \"\", \n                 \"label\": \"\" , \n                 \"kind\" : \"\" \n                 } \n             ] \n         } \n } <\/pre>\n\n\n\n<p>If you&#8217;re using <code>getUserMedia()<\/code> within an , you can request permission just for that frame, which is clearly more secure than requesting a more general permission. Here, indicate we need the ability to use both camera and microphone:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;iframe src=\"https:\/\/my-website\/rtc\" allow=\"camera;microphone\"&gt;\n&lt;\/iframe&gt;<\/pre>\n\n\n\n<p><strong>Error Codes<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Error Code<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td>1144<\/td><td>Device Access denied<\/td><\/tr><tr><td>1146&nbsp;<\/td><td>Failed to execute getUserMedia on MediaDevices<\/td><\/tr><tr><td>1150&nbsp;<\/td><td>Unknown Reason<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3><strong>Browser Compatibility<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"1024\" height=\"421\" src=\"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-content\/uploads\/2025\/04\/Browser-Compatibility-Image-1024x421-1.png\" alt=\"\" class=\"wp-image-7333\" srcset=\"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-content\/uploads\/2025\/04\/Browser-Compatibility-Image-1024x421-1.png 1024w, https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-content\/uploads\/2025\/04\/Browser-Compatibility-Image-1024x421-1-300x123.png 300w, https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-content\/uploads\/2025\/04\/Browser-Compatibility-Image-1024x421-1-768x316.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><strong>&nbsp;<\/strong><\/p>\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=\"..\/how-to-use\/\">How to use Web SDK<\/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=\"..\/local-stream\/\">Create Local Stream<\/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>This MediaStream API provides a way to access device cameras and microphones which may be used to create Media Stream to publish into Video Room. It also exposes information about devices able to capture and render media. You can initiate a Stream&nbsp;using&nbsp;either the browser\u2019s default Audio Device or&nbsp;by&nbsp;specifying&nbsp;the ID of&nbsp;the Audio Device connected to the device running the client application which requires you to get the Device IDs of all&hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"parent":3724,"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":"This MediaStream API provides a way to access device cameras and microphones which may be used to create Media Stream to publish into Video Room. It also exposes information about devices able to capture and render media. You can initiate a Stream&nbsp;using&nbsp;either the browser\u2019s default Audio Device or&nbsp;by&nbsp;specifying&nbsp;the ID of&nbsp;the Audio Device connected to the&hellip;","_links":{"self":[{"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/pages\/4076"}],"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=4076"}],"version-history":[{"count":0,"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/pages\/4076\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/pages\/3724"}],"wp:attachment":[{"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/media?parent=4076"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}