After initializing the stream, you need to publish it in the room so that the other users in the room can see and hear the user.  The methods to publish, unpublish, and close a local stream are explained in this section.

Table of Contents

Publish Local Stream

The EnxRoom.publish() method publishes a local stream in the connected room. 

Class: EnxRoom

Method: public void publish(EnxStream localStream)

Parameters:

  • localStream – Initiated Stream Object

Observers:

  • onPublishedStream – Acknowledgment to the Stream publisher when the stream gets published.
  • onStreamAdded – Notification to everyone in the Room when a new stream is published in the Room.
room.publish(localStream);  // To publish initialized Local Stream

public void onPublishedStream(EnxStream stream) {
     // Your Stream is published
}

public void onStreamAdded(EnxStream stream) {
     // Announcement of a new Stream in the Room
     // You may subscribe to the Stream
}

Error Codes / Exceptions

CodeDescription
5013Failed to publish Stream.
5015Unable to publish a Stream without audio, video, and data.
5016Unable to publish a Stream with illegible attributes.
5022Failed to publish Stream because Floor Access not received in lecture mode room.
5023The Stream has already been published.
5024Repeated publish() call while Stream Publishing is in process.
5025Failed to publish stream because publish() call is made on a Remote Stream.
1170The current subscription doesn’t support the publishing of Stream.

Unpublish Local Stream

The EnxRoom.unpublish() method disconnects the local stream from the room. Unpublishing a stream does not release the device access so that subsequent republishing does not require device-access-permission.  

Class: EnxRoom

Method: public void unpublish() – No Parameter required.

Observers: onRemoveStream - Notification to everyone in the Room when a Stream is removed from the Room.

room.unpublish();  // To unpublish all Local Streams

public void onRemoveStream(EnxStream stream) {
     // To announce in the room that a stream has been removed from the Room.
}

Error Codes / Exceptions

CodeDescription
5029Repeated unpublish() call made while previous unpublish request is in process.
5030Non-Contextual use of method when the user tries to unpublish a stream before publishing it.