Publishing Streams

Publish a Stream to a Channel

Before allowing the end user to publish video you should make sure you have received a VIDEO_STATE_AVAILABLE state from the onVideoAvailabilityChange event.

To publish the stream you call the publishStream() method. By default this will publish both the video and audio track within the current local media stream.

aloVideo.publishStream();

If you wish to specify which tracks to publish you can provide the sendAudio and sendVideo options.

The following is an example when you publish the stream with video and without the audio:

aloVideo.publishStream({sendVideo: true, sendAudio: false});

You can also change which tracks are published after calling the publishStream method as well. See Modifying Published Streams.

See Rendering Streams for information about rendering streams.

Unpublish a Stream

You may unpublish video in the channel and remain connected to a video channel (so you still see and hear others) using the unpublishStream() methhod.

aloVideo.unpublishStream();

Example Event Payloads

// onVideoAvailabilityChange
detail : {
    state : 'VIDEO_STATE_UNAVAILABLE'
}

detail : {
    state : 'VIDEO_STATE_AVAILABLE'
}

//onParticipantsChanged
detail : {
    channel: VideoChannel{...},
    currentParticipantId: "dhsdjfhgs-dfsdfdd",
    participants: [Participant, Participant]
}


// onPublishedVideoChange
detail : {
    channel: VideoChannel{...},
    isPublished: true,
    participant: Participant{...}
}

Last updated