Viewer events

In this new release we have added new events that can be received by the viewer application to detect:

  • when a new source has been published within the stream
  • when a source has been unpublished within the stream
  • the simulcast/svc layer information for the published video tracks of each source
  • VAD multiplexing, indicating when a source id is being multiplexed into the audio track based on the voice activity level

The events are delivered over the websocket connection established by the viewer application with the Millicast servers.

If you use the Millicast Javascript SDK, you can subscribe to the events when using the events attribute on the connect methods specifying which events you want to receive:

//Create a new instance
const millicastView = new View(streamName, tokenGenerator, video)

//Start connection to publisher
await millicastView.connect({
    events: ["active", "inactive", "vad", "layers"]
})

millicastView.on("broadcastEvent", (event) =>
{
    //Get event name and data
    const { name, data } = event;

    switch (name)
    {
        case "active":
            //A source has been started on the steam
            break;
        case "inactive":
            //A source has been stopped on the steam
            break;
        case "vad":
            //A new source was multiplexed over the vad tracks
            break;
        case "layers":
            //Updated layer information for each simulcast/svc video track
            break;
    }
});

Did this page help you?