@millicast/sdk-interactivity
Version:
Dolby Millicast Interactivity SDK
78 lines • 2.33 kB
TypeScript
import { MediaTrackInfo, View } from '@millicast/sdk';
import { ILogger } from 'js-logger';
import { SourceIdentifier } from './sourceIdentifier';
export declare class Source {
#private;
/** @ignore */
get videoMediaId(): string;
/** Gets the source identifier. */
get identifier(): SourceIdentifier;
/** The actual audio / video stream. */
get mediaStream(): MediaStream;
/** @hidden */
constructor(logger: ILogger, viewer: View, sourceId: string, tracks: MediaTrackInfo[]);
/**
* Request to start receiving the source.
*/
receive: () => Promise<void>;
/**
* Stop receiving the source.
*/
stop: () => Promise<void>;
/**
* Project a source.
*/
private project;
/**
* Threshold beyond which the publisher is considered to be speaking.
* @hidden
*/
readonly IS_SPEAKING_THRESHOLD = 0.002;
/**
* Gets if the remote source is considered to be speaking or not.
*
* @example
* ```ts
* import { Publisher, Room, Source } from '@millicast/sdk-interactivity';
*
* const room = new Room({
* streamName,
* streamAccountId,
* });
*
* room.on('sourceAdded', async (publisher: Publisher, source: Source) => {
* // Request to receive the source
* await source.receive();
*
* // Display the source on the UI
* const videoElement = document.getElementById('remote-video');
* videoElement.srcObject = new MediaStream([source.videoTrack]);
* videoElement.play();
*
* setInterval(async () => {
* const isSpeaking = await source.isSpeaking();
* console.log('is speaking', isSpeaking);
* }, 1000);
* });
*
* await room.watch();
* ```
*
* @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=source.d.ts.map