Representation of a stream. This class is the starting point for the SDK. Create a instance of this class, connect to the Dolby Millicast platform and start receiving & publishing streams.

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

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

// Start publishing to the stream and listen to the available sources
await room.connect({
publisherName,
publishToken,
constraints: {
audio: true,
video: true,
},
});

Hierarchy

  • EventEmitter
    • Room

Implements

Implemented by

Constructors

Properties

MAX_SOURCES: number = 5

Maximum number of sources that can be published from a single client.

Accessors

  • get viewer(): View
  • Gets the Millicast View object once the SDK has been initialized.

    Returns View

Methods

  • Connects to the stream. This function will publish a stream and listen to the sources.

    Parameters

    Returns Promise<PublishedSource>

    A Promise whose fulfillment handler receives a PublishedSource object when the source has successfully been published to the platform.

  • Leaves the stream. Will stop publishing into the stream and will stop listening to it.

    Note, the audio / video stream will be stopped to release allocated resources.

    Returns void

    room.leave();
    
  • Adds the listener function to the end of the listeners array for the event named eventName. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of eventNameand listener will result in the listener being added, and called, multiple times.

    Returns a reference to the EventEmitter, so that calls can be chained.

    Type Parameters

    Parameters

    • eventName: N

      The name of the event.

    • listener: RoomEvents[N]

      The callback function.

    Returns this

  • Publishes a video / audio feed to a stream.

    Parameters

    Returns Promise<PublishedSource>

    A Promise whose fulfillment handler receives a PublishedSource object when the source has successfully been published to the platform.

    Error if you have not set the publisherName when connecting to the stream.

    Error if you've reached the maximum number of sources that can be published from a single publisher.

  • Stops publishing the source to the stream.

    Parameters

    Returns void

  • Start watching the stream.

    Parameters

    • Optionaloptions: WatchOptions

      Additional options to watch to the stream.

    Returns Promise<void>