Skip to main content
Version: v1.39.0

AmazonIVSBroadcastClient

A class implementing the Web Broadcast SDK API.

Constructors​

new AmazonIVSBroadcastClient()​

new AmazonIVSBroadcastClient(config): AmazonIVSBroadcastClient

Creates an instance of the AmazonIVSBroadcastClient.

Parameters​

ParameterTypeDescription
configConfigBroadcastClientConfig

Returns​

AmazonIVSBroadcastClient

Properties​

config​

config: Config

BroadcastClientConfig


emitter​

emitter: IEventEmitter

Methods​

addAudioInputDevice()​

addAudioInputDevice(device, name): Promise<void>

Adds the specified audio input to the broadcast stream.

Parameters​

ParameterTypeDescription
deviceMediaStreamAudio input to add to the stream.
namestringUnique string you assign to the audio-input device.

Returns​

Promise<void>


addImageSource()​

addImageSource(image, name, position): Promise<void>

Adds the specified image to the broadcast stream.

Parameters​

ParameterTypeDescription
imageHTMLImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmapImage to add to the stream. Must be of type HTMLImageElement, HTMLVideoElement, HTMLCanvasElement or ImageBitmap.
namestringUnique string you assign to the image.
positionVideoCompositionThe desired position of the image in the stream.

Returns​

Promise<void>


addVideoInputDevice()​

addVideoInputDevice(device, name, position): Promise<void>

Adds the specified video input to the broadcast stream.

Parameters​

ParameterTypeDescription
deviceMediaStreamVideo input to add to the stream.
namestringUnique string you assign to the video-input device.
positionVideoCompositionThe desired position of the video in the stream.

Returns​

Promise<void>


attachPreview()​

attachPreview(element): void

Attach a HTMLCanvasElement to display a preview of the output.

Parameters​

ParameterTypeDescription
elementHTMLCanvasElementAn HTMLCanvasElement on which to draw the composited preview.

Returns​

void


delete()​

delete(): void

Explicitly stop and/or free internal components that would otherwise leak.

Returns​

void


detachPreview()​

detachPreview(): void

Detach the HTMLCanvasElement preview element.

Returns​

void


disableAudio()​

disableAudio(): void

Disables all audio content from the stream.

Returns​

void


disableVideo()​

disableVideo(): void

Disables all video content from the stream.

Returns​

void


enableAudio()​

enableAudio(): void

Enables all audio content from the stream if previously disabled.

Returns​

void


enableVideo()​

enableVideo(): void

Enables all video content from the stream if previously disabled.

Returns​

void


exchangeVideoDevicePositions()​

exchangeVideoDevicePositions(name1, name2): void

Exchanges (swaps) the VideoComposition settings of two video devices.

Parameters​

ParameterTypeDescription
name1stringUnique name of the video device to swap (one of two).
name2stringUnique name of the video device to swap (two of two).

Returns​

void


getAudioContext()​

getAudioContext(): AudioContext

Returns the Media Stream Manager's Audio Context to allow a user to have more direct control over the audio stream.

Returns​

AudioContext


getAudioInputDevice()​

getAudioInputDevice(name): Maybe<MediaStream>

Gets the MediaStream of the specified audio device.

Parameters​

ParameterTypeDescription
namestringUnique name of the audio device.

Returns​

Maybe<MediaStream>


getCanvasDimensions()​

getCanvasDimensions(): CanvasDimensions

Gets the dimensions of the canvas on which the stream is drawn.

Returns​

CanvasDimensions


getConnectionState()​

getConnectionState(): ConnectionState

Gets the state of the webRTC connection.

Returns​

ConnectionState


getSessionId()​

getSessionId(): undefined | string

Get active session ID

Returns​

undefined | string


getVideoInputDevice()​

getVideoInputDevice(name): Maybe<VideoDevice>

Gets the VideoDevice of the specified video-input device.

Parameters​

ParameterTypeDescription
namestringUnique name of the video-input device.

Returns​

Maybe<VideoDevice>


off()​

off<Key>(event, callback): void

Deregisters (stops) a specified callback to a given event.

Type Parameters​

Type Parameter
Key extends string

Parameters​

ParameterTypeDescription
eventKeyThe event to which the callback was registered.
callbackCallbackThe callback to remove.

Returns​

void


on()​

on<Key>(event, callback): void

Registers (starts) a specified callback to a specified event.

Type Parameters​

Type Parameter
Key extends string

Parameters​

ParameterTypeDescription
eventKeyThe event to listen to.
callbackCallbackThe callback that will called when the event is fired.

Returns​

void


removeAudioInputDevice()​

removeAudioInputDevice(name): void

Removes the specified audio-input device from the stream.

Parameters​

ParameterTypeDescription
namestringUnique name of the device to remove.

Returns​

void


removeImage()​

removeImage(name): void

Removes the specified image from the stream.

Parameters​

ParameterTypeDescription
namestringUnique name of the image to remove.

Returns​

void


removeVideoInputDevice()​

removeVideoInputDevice(name): void

Removes the specified video-input device from the stream.

Parameters​

ParameterTypeDescription
namestringunique name of the device to remove.

Returns​

void


startBroadcast()​

startBroadcast(streamKey, ingestEndpoint?): Promise<void | BroadcastClientError>

Starts broadcasting to IVS.

Parameters​

ParameterTypeDescription
streamKeystringIVS-generated stream key for your IVS channel.
ingestEndpoint?stringIVS-generated ingest endpoint for your IVS channel. This is optional but will need to be specified in either the config or as a parameter of this function.

Returns​

Promise<void | BroadcastClientError>

Throws​

Throws a BroadcastClientError if unable to stream.


stopBroadcast()​

stopBroadcast(): void

Stops the broadcast.

Returns​

void


updateVideoDeviceComposition()​

updateVideoDeviceComposition(name, composition): void

Updates the position of the specified video device in the stream.

Parameters​

ParameterTypeDescription
namestringUnique name of the device to update.
compositionVideoCompositionThe new position.

Returns​

void