{"id":4106,"date":"2021-11-08T19:01:51","date_gmt":"2021-11-08T11:01:51","guid":{"rendered":"https:\/\/www.enablex.io\/developer\/?page_id=4106"},"modified":"2025-03-03T19:03:05","modified_gmt":"2025-03-03T11:03:05","slug":"active-talkers","status":"publish","type":"page","link":"https:\/\/doc.smartflomeet.ttns.in\/developer\/video-api\/client-api\/web-toolkit\/active-talkers\/","title":{"rendered":"Active Talkers: Web SDK &#8211; Video API"},"content":{"rendered":"\n<h4>Table of Contents<\/h4>\n\n\n\n<ul id=\"block-b4a4d06d-f53a-4cf9-baf9-75dd5f9a768f\"><li><a href=\"#active-talkers\">Handle Active Talkers<\/a><ul><li><a href=\"#get-talker-count\">Get Talker Count<\/a><\/li><li><a href=\"#set-talker-count\">Set Talker Count<\/a><\/li><li><a href=\"#get-max-talkers\">Get Maximum Permissible Talker Count<\/a><\/li><\/ul><\/li><\/ul>\n\n\n\n<a name=\"active-talkers\"><\/a>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2>Handle Active Talkers<\/h2>\n\n\n\n<p>To avoid excessive consumption of the server and client resources,\u00a0Portal sends a maximum of 12 actively talking users in the Room\u00a0to the client endpoint. Additionally, it sends Screen Sharing (StreamID# 101) and Canvas Stream (StreamID# 102)\u00a0if the client application supports these features.\u00a0The decision on which of the participant\u2019s streams would be played depends upon the\u00a0Active Talker List.\u00a0<\/p>\n\n\n\n<p>After getting connected to the Room, you need to subscribe to the Remote Streams available in the <code>room.remoteStreams[]<\/code> in the <a href=\"..\/..\/appendix\/#room-meta\" target=\"_blank\" rel=\"noreferrer noopener\">Room Meta Info<\/a>. The total number of Remote Streams is restricted by the <code>max_active_talkers<\/code> configured during <a href=\"..\/..\/..\/server-api\/rooms-route\/#create-room\">Room Creation<\/a>. Apart from these, you also need to subscribe to Screen share and Canvas Stream.<\/p>\n\n\n\n<p>After you connect to the room and subscribe to the available Streams, the&nbsp;<code>active-talkers-updated<\/code>&nbsp;event is triggered,&nbsp;which creates a&nbsp;new&nbsp;entry in the Active Talker List. This list keeps getting updated depending upon the&nbsp;latest talker in the Room. Hence, the Active Talker List&nbsp;contains a list of talkers in ascending order at any point&nbsp;in time which means that the latest talker would be&nbsp;moved up in the list.&nbsp;Therefore, you may expect to receive the event too frequently in a noisy room. The list of Active Talkers is available in JSON format and sent through the <code>active-talkers-updated<\/code> event&nbsp;to each connected endpoint whenever there is a change in the Active Talker List.<\/p>\n\n\n\n<p>Apart from the activity level,\u00a0Platform also allows\u00a0<a rel=\"noreferrer noopener\" href=\"..\/pin-user\/\" target=\"_blank\">pinning of user streams<\/a> in the Active Talker List regardless of their activity level in the Room. So, the Active Talkers List consists\u00a0of the\u00a0inactive\u00a0pinned users\u00a0and active talkers in ascending order.\u00a0\u00a0<\/p>\n\n\n\n<p>It must also be noted that the Active Talkers List contains Remote Streams only and hence the Active Talkers List varies for each participant&nbsp;in the Room.&nbsp;<\/p>\n\n\n\n<p><strong>Event Notifications:<\/strong> <code>active-talkers-updated<\/code><\/p>\n\n\n\n<p><strong>Active Talkers List JSON<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{    \"active\" : true,\n      \"activeList\": [\n           {   \"clientId\" : \"String\", \n               \"mediatype\" : \"audiovideo\", \/\/ Enum: audiovideo, audioonly\n               \"name\" : \"String\",\n               \"reason\" : \"user\",\n               \"streamId\" : Number,\n               \"videoaspectratio\" : \"16:9\", \n               \"videomuted\" : Boolean,\n               \"pinned\" : Boolean\n           }\n       ]\n   }<\/pre>\n\n\n\n<p>Once you have subscribed to all the Streams in the Active Talker List, you can now&nbsp;play them in a FIFO manner.&nbsp;You can use the&nbsp;StreamID&nbsp;out of the Active Talker List to pick the latest Stream&nbsp;from&nbsp;<code>room.remoteStreams[]<\/code>&nbsp;and&nbsp;play them on the UI.&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">room.addEventListener('active-talkers-updated', function (event) {\n       TalkerList = event.message.activeList;\n       for (var i = 0; i &lt; TalkerList.length; i++) {\n           if (ATUserList[i] &amp;&amp; ATUserList[i].streamId) {\n               var stream  = room.remoteStreams.get(ATUserList[i].streamId);\n               var stream_id   = ATUserList[i].streamId;\n               var username    = ATUserList[i].name;\n               stream.play(\"DOM_ELEMENT_ID\", PlayerOptions);\n           }\n       }                       \n }<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<a name=\"get-talker-count\"><\/a>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3>Get Talker Count<\/h3>\n\n\n\n<p>The&nbsp;<code>EnxRoom<\/code>.<code>getTalkerCount()<\/code>&nbsp;method provides you the number of active talkers to be received through&nbsp;<code>active-talkers-updated<\/code>&nbsp;event. The method returns the number of currently active streams in the Room restricted either by the&nbsp;<a href=\"#get-max-talkers\" target=\"_blank\" rel=\"noreferrer noopener\">maximum permissible talker count<\/a>&nbsp;or by the&nbsp;<a href=\"#set-talker-count\" target=\"_blank\" data-type=\"internal\" data-id=\"#set-talker-count\" rel=\"noreferrer noopener\">set talker count API<\/a>&nbsp;when invoked by the application or the user through UI. &nbsp;<\/p>\n\n\n\n<p><strong>Class:<\/strong> EnxRoom<\/p>\n\n\n\n<p><strong>Method<\/strong>:  <code>EnxRoom.getTalkerCount( Callback )<\/code>  <\/p>\n\n\n\n<p><strong>Returns:<\/strong><\/p>\n\n\n\n<p>maxTalkers &#8211;  Maximum number of active talker streams currently allowed to be received at the Client Endpoint. <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">room.getTalkerCount( function(response) {\n     \/\/ Talker info in response JSON:\n     \/\/ { \"result\": 0, \"maxTalkers\": 4 } \n});<\/pre>\n\n\n\n<a name=\"set-talker-count\"><\/a>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3>Set Talker Count<\/h3>\n\n\n\n<p>The&nbsp;<code>EnxRoom.setTalkerCount()<\/code>&nbsp;method is used to set the number of active talkers in the Active Talkers List to a&nbsp;particular value not exceeding the&nbsp;<a href=\"#get-max-talkers\" target=\"_blank\" rel=\"noreferrer noopener\">maximum permissible talker count<\/a>. This could either be ingrained&nbsp;at the application level or be&nbsp;implemented as a UI feature where the end-user has the flexibility to control the number of remote streams they want to receive.&nbsp; This method allows you to control how many Streams you would like to receive.&nbsp;<\/p>\n\n\n\n<p><strong>Method<\/strong>:  <code>EnxRoom.setTalkerCount(numTalkers, Callback)<\/code> <\/p>\n\n\n\n<p><strong>Parameters<\/strong>: <\/p>\n\n\n\n<p><code>numTalkers <\/code>&#8211; No. of talkers you want to receive. Range limited by&nbsp;<a href=\"..\/..\/..\/server-api\/rooms-route\/#create-room\" target=\"_blank\" rel=\"noreferrer noopener\">max_active_talkers<\/a>, typically 0-12<\/p>\n\n\n\n<ul><li>If you set  <code>numTalkers<\/code> to any value from 1 to 12, you receive those many talkers in the Active Talker Lists in the list.<\/li><li>If you set  <code>numTalkers<\/code> to 0 (zero), then the list doesn\u2019t become empty, it carries 3 audio streams and no video Streams.<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">room.setTalkerCount(5, function(response) {\n     \/\/ Set Talker info in response JSON:\n     \/\/ { \"result\": 0, \"maxTalkers\": 5 } \n });<\/pre>\n\n\n\n<p><strong>Error Codes \/ Exceptions<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Code<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td>4106<\/td><td>Invalid Talker Count range. Valid range: 1-12<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<a name=\"get-max-talkers\"><\/a>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3>Get Maximum Permissible Talker Count<\/h3>\n\n\n\n<p>The&nbsp;<code>EnxRoom.getMaxTalkers()<\/code>&nbsp;method provides the maximum active talkers allowed for the Room as per max_active_talkers&nbsp;configuration during&nbsp;<a href=\"..\/..\/..\/server-api\/rooms-route\/#create-room\" target=\"_blank\" rel=\"noreferrer noopener\">Room&nbsp;Creation<\/a>.&nbsp;This count could be of interest to the user if they choose to receive&nbsp;less&nbsp;active talkers in the Room.&nbsp;By&nbsp;default,&nbsp;the&nbsp;max_active_talkers&nbsp;is&nbsp;restricted to 12.&nbsp;<\/p>\n\n\n\n<p><strong>Class:<\/strong> EnxRoom<\/p>\n\n\n\n<p><strong>Method:<\/strong>&nbsp;<code>EnxRoom.getMaxTalkers( Callback )<\/code>&nbsp;<\/p>\n\n\n\n<p><strong>Returns:<\/strong><\/p>\n\n\n\n<p><code>maxTalkers<\/code> &#8211; Maximum number of talkers permitted in the Room as per Room configuration.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">room.getMaxTalkers( function(response) {\n     \/\/ Maximum Talker info in response JSON:\n     \/\/ { \"result\": 0, \"maxTalkers\": 6 } \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=\"..\/subscribing-remote-streams\/\">Subscribe Remote Streams<\/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=\"..\/receiving-video-quality\/\">Set Desired Video Quality<\/a>  \u2192 <\/p>\n<\/div>\n<\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Table of Contents Handle Active Talkers Get Talker Count Set Talker Count Get Maximum Permissible Talker Count Handle Active Talkers To avoid excessive consumption of the server and client resources,\u00a0Portal sends a maximum of 12 actively talking users in the Room\u00a0to the client endpoint. Additionally, it sends Screen Sharing (StreamID# 101) and Canvas Stream (StreamID# 102)\u00a0if the client application supports these features.\u00a0The decision on which of the participant\u2019s streams would&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":"Table of Contents Handle Active Talkers Get Talker Count Set Talker Count Get Maximum Permissible Talker Count Handle Active Talkers To avoid excessive consumption of the server and client resources,\u00a0Portal sends a maximum of 12 actively talking users in the Room\u00a0to the client endpoint. Additionally, it sends Screen Sharing (StreamID# 101) and Canvas Stream (StreamID#&hellip;","_links":{"self":[{"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/pages\/4106"}],"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=4106"}],"version-history":[{"count":0,"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/pages\/4106\/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=4106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}