{"id":4103,"date":"2021-11-08T18:33:05","date_gmt":"2021-11-08T10:33:05","guid":{"rendered":"https:\/\/www.enablex.io\/developer\/?page_id=4103"},"modified":"2025-02-24T16:47:16","modified_gmt":"2025-02-24T08:47:16","slug":"subscribing-remote-streams","status":"publish","type":"page","link":"https:\/\/doc.smartflomeet.ttns.in\/developer\/video-api\/client-api\/web-toolkit\/subscribing-remote-streams\/","title":{"rendered":"Subscribing Remote Streams: Web SDK &#8211; Video API"},"content":{"rendered":"\n<p>The <code>EnxRoom.subscribe()<\/code>&nbsp;method is used to receive the media stream of other users connected to the Room.&nbsp;This method must be called for each participant\u2019s media stream individually to&nbsp;receive it.&nbsp;&nbsp;<\/p>\n\n\n\n<p>After being connected to the Room, the client application can access the list&nbsp;of streams in the Room through the&nbsp;<a rel=\"noreferrer noopener\" href=\"..\/..\/appendix\/#room-meta\" target=\"_blank\">Room Meta Information<\/a>&nbsp;ie.&nbsp;{ streams: [] }&nbsp;and call the&nbsp;EnxRoom.subscribe()&nbsp;on each stream.&nbsp;The user can subscribe to a maximum of 12 active talkers in the room,&nbsp;one stream for screen sharing (StreamID# 11),&nbsp;and one stream for canvas streaming (StreamID# 21)&nbsp;if the client application supports screen sharing or canvas streaming.&nbsp;This means that the user can see&nbsp;a&nbsp;maximum 12 participants on the UI and&nbsp;these&nbsp;participants keep getting updated as per their activity in the Room.&nbsp;This is further explained in the&nbsp;<a href=\"..\/active-talkers\/#active-talkers\" target=\"_blank\" rel=\"noreferrer noopener\">Handle Active Talkers<\/a> section.<\/p>\n\n\n\n<p>The user\u00a0does\u00a0not\u00a0need to\u00a0subscribe to their local stream and\u00a0the Portal also facilitates the publisher to receive their own screen sharing and canvas streaming\u00a0without explicitly subscribing to it. In short,\u00a0a user must only subscribe to remote streams in the room.\u00a0<\/p>\n\n\n\n<p><strong>Method<\/strong>: <code>EnxRoom.subscribe(RemoteStream, SubsOptions, Callback)<\/code><\/p>\n\n\n\n<p><strong>Parameters:<\/strong><\/p>\n\n\n\n<ul><li><code>RemoteStream <\/code>&#8211; The Stream object that needs to be subscribed\/received.<\/li><li><code>SubsOptions <\/code>&#8211; Lists&nbsp;configurable&nbsp;stream subscription options as given below:&nbsp;<ul><li><code>audio <\/code>&#8211; Boolean. Set to <em>true<\/em> to subscribe to Audio of the Stream.<\/li><li><code>video <\/code>&#8211; Boolean. Set to <em>true<\/em> to subscribe to Video of the Stream.<\/li><li><code>data <\/code>&#8211; Boolean. Set to <em>true<\/em> to subscribe to Data of the Stream.<\/li><\/ul><\/li><\/ul>\n\n\n\n<p><strong>Event Notification:<\/strong><\/p>\n\n\n\n<ul><li><code>stream-subscribed<\/code> &#8211; Acknowledgment to the subscriber when they have subscribed to the Stream successfully.<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">var subsOptiions = {\n    audio: true,\n    video: true,\n    data: true\n};\n\n\/\/ Subscribe to all Streams in Room Metaa\nfor (var i = 0; i &lt; success.streams.length; i++) {\n    room.subscribe(success.streams[i],  subsOptiions  );  \n}  \n\nroom.addEventListener(\"stream-subscribed\", function(event) {\n    \/\/ Stream subscribed\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=\"..\/mute-audio-video-stream\/\">Mute-Unmute Audio-Video<\/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=\"..\/active-talkers\/\">Handle Active Talkers<\/a>  \u2192 <\/p>\n<\/div>\n<\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The EnxRoom.subscribe()&nbsp;method is used to receive the media stream of other users connected to the Room.&nbsp;This method must be called for each participant\u2019s media stream individually to&nbsp;receive it.&nbsp;&nbsp; After being connected to the Room, the client application can access the list&nbsp;of streams in the Room through the&nbsp;Room Meta Information&nbsp;ie.&nbsp;{ streams: [] }&nbsp;and call the&nbsp;EnxRoom.subscribe()&nbsp;on each stream.&nbsp;The user can subscribe to a maximum of 12 active talkers in the room,&nbsp;one stream&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":"The EnxRoom.subscribe()&nbsp;method is used to receive the media stream of other users connected to the Room.&nbsp;This method must be called for each participant\u2019s media stream individually to&nbsp;receive it.&nbsp;&nbsp; After being connected to the Room, the client application can access the list&nbsp;of streams in the Room through the&nbsp;Room Meta Information&nbsp;ie.&nbsp;{ streams: [] }&nbsp;and call the&nbsp;EnxRoom.subscribe()&nbsp;on each&hellip;","_links":{"self":[{"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/pages\/4103"}],"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=4103"}],"version-history":[{"count":0,"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/pages\/4103\/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=4103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}