Type Alias RoomEvents

RoomEvents: {
    publisherJoined(publisher: Publisher): void;
    publisherLeft(publisher: Publisher): void;
    sourceAdded(publisher: Publisher, source: Source): void;
    sourceRemoved(publisher: Publisher, sourceId: SourceIdentifier): void;
    viewercount(count: number): void;
}

Events triggered by the Room object.

Type declaration

  • publisherJoined:function
    • Event triggered when a new publisher starts publishing to the stream.

      Parameters

      • publisher: Publisher

        The Publisher object that represents the publisher starting publishing to the stream.

      Returns void

      import { Publisher, Room } from '@millicast/sdk-interactivity';

      const room = new Room({
      streamName,
      streamAccountId,
      publisherName,
      });

      room.on('publisherJoined', (publisher: Publisher) => {
      console.log(`The publisher ${publisher.name} has joined the stream.`);
      // TODO: Add the video element to the UI
      });
  • publisherLeft:function
    • Event triggered when a publisher stops publishing to the stream.

      Parameters

      • publisher: Publisher

        Publisher object that represents the publisher that stopped publishing to the stream.

      Returns void

      import { Publisher, Room } from '@millicast/sdk-interactivity';

      const room = new Room({
      streamName,
      streamAccountId,
      publisherName,
      });

      room.on('publisherLeft', (publisher: Publisher) => {
      console.log(`The publisher ${publisher.name} has left.`);
      // TODO: Remove the video element from the UI
      });
  • sourceAdded:function
    • Event triggered when a new source is being published to the stream.

      Parameters

      • publisher: Publisher

        The Publisher object that represents the publisher starting publishing a new source to the stream.

      • source: Source

        The Source object that was added to the stream.

      Returns void

      import { Publisher, Room, Source } from '@millicast/sdk-interactivity';

      const room = new Room({
      streamName,
      streamAccountId,
      publisherName,
      });

      room.on('sourceAdded', async (publisher: Publisher, source: Source) => {
      console.log(`The publisher ${publisher.name} has started publishing the source ${source.sourceId.sourceName} (${source.sourceId.sourceType}).`);
      // Request to receive the source
      await source.receive();
      // TODO: Add the media stream to the UI
      const stream = source.mediaStream;
      });
  • sourceRemoved:function
    • Event triggered when a source stopped being published.

      Parameters

      Returns void

      import { Publisher, Room, SourceIdentifier } from '@millicast/sdk-interactivity';

      const room = new Room({
      streamName,
      streamAccountId,
      publisherName,
      });

      room.on('sourceRemoved', (publisher: Publisher, sourceId: SourceIdentifier) => {
      // TODO: Remove the video from the UI
      });
  • viewercount:function
    • Event triggered from time to time to indicate the number of viewers connected to the stream.

      Parameters

      • count: number

        Number of viewers connected to the stream.

      Returns void

      import { Room } from '@millicast/sdk-interactivity';

      const room = new Room({
      streamName,
      streamAccountId,
      publisherName,
      });

      room.on('viewercount', (count: number) => {
      console.log(count, 'viewer(s) connected.');
      });