UNPKG

@millicast/sdk-interactivity

Version:

Dolby Millicast Interactivity SDK

85 lines 2.46 kB
import { Publish } from '@millicast/sdk'; import { ILogger } from 'js-logger'; import { PublishOptions } from './types/options'; import { SourceIdentifier } from './sourceIdentifier'; /** * Represents a published source. */ export declare class PublishedSource { #private; /** * Gets the {@link SourceIdentifier} object representing the source identifier. */ get sourceId(): SourceIdentifier; /** * Gets the audio track. */ get audioTrack(): MediaStreamTrack; /** * Gets the video track. */ get videoTrack(): MediaStreamTrack; /** * Gets the Millicast {@link !Publish Publish} object used to publish the source to the stream. */ get publisher(): Publish; /** @hidden */ constructor(logger: ILogger, streamName: string, sourceId: SourceIdentifier); /** @hidden */ publish: (options: PublishOptions) => Promise<void>; /** @hidden */ unpublish: () => void; /** * Threshold beyond which the publisher is considered to be speaking. * @hidden */ readonly IS_SPEAKING_THRESHOLD = 0.002; /** * Gets if the publisher is considered to be speaking or not. * * @example * ```ts * import { Room } from '@millicast/sdk-interactivity'; * * const room = new Room({ * streamName, * streamAccountId, * }); * * const localSource = await room.connect({ * publishToken, * publisherName, * constraints: { * audio: true, * video: true, * }, * }); * * const videoElement = document.getElementById("local-video"); * videoElement.srcObject = new MediaStream([localSource.videoTrack]); * videoElement.play(); * * setInterval(async () => { * const isSpeaking = await localSource.isSpeaking(); * console.log('is speaking', isSpeaking); * }, 1000); * ``` * * @returns A {@link !Promise Promise} whose fulfillment handler receives a flag indicating if the publisher is considered to be speaking. */ isSpeaking: () => Promise<boolean>; /** * Gets if the audio track is muted or not. * If no audio track is available, this returns `true`. */ get isMuted(): boolean; /** * Mutes the audio track. */ mute: () => void; /** * Unmutes the audio track. */ unmute: () => void; } //# sourceMappingURL=publishedSource.d.ts.map