AmazonIVSBroadcastClient
A class implementing the Web Broadcast SDK API.
Constructors
new AmazonIVSBroadcastClient()
new AmazonIVSBroadcastClient(
config
):AmazonIVSBroadcastClient
Creates an instance of the AmazonIVSBroadcastClient.
Parameters
Parameter | Type | Description |
---|---|---|
config | Config | BroadcastClientConfig |
Returns
Properties
config
config:
Config
emitter
emitter:
IEventEmitter
Methods
addAudioInputDevice()
addAudioInputDevice(
device
,name
):Promise
<void
>
Adds the specified audio input to the broadcast stream.
Parameters
Parameter | Type | Description |
---|---|---|
device | MediaStream | Audio input to add to the stream. |
name | string | Unique 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
Parameter | Type | Description |
---|---|---|
image | HTMLImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | Image to add to the stream. Must be of type HTMLImageElement, HTMLVideoElement, HTMLCanvasElement or ImageBitmap. |
name | string | Unique string you assign to the image. |
position | VideoComposition | The 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
Parameter | Type | Description |
---|---|---|
device | MediaStream | Video input to add to the stream. |
name | string | Unique string you assign to the video-input device. |
position | VideoComposition | The 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
Parameter | Type | Description |
---|---|---|
element | HTMLCanvasElement | An 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
Parameter | Type | Description |
---|---|---|
name1 | string | Unique name of the video device to swap (one of two). |
name2 | string | Unique 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
Parameter | Type | Description |
---|---|---|
name | string | Unique name of the audio device. |
Returns
Maybe
<MediaStream
>
getCanvasDimensions()
getCanvasDimensions():
CanvasDimensions
Gets the dimensions of the canvas on which the stream is drawn.
Returns
getConnectionState()
getConnectionState():
ConnectionState
Gets the state of the webRTC connection.
Returns
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
Parameter | Type | Description |
---|---|---|
name | string | Unique name of the video-input device. |
Returns
off()
off<
Key
>(event
,callback
):void
Deregisters (stops) a specified callback to a given event.
Type Parameters
Type Parameter |
---|
Key extends string |
Parameters
Parameter | Type | Description |
---|---|---|
event | Key | The event to which the callback was registered. |
callback | Callback | The 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
Parameter | Type | Description |
---|---|---|
event | Key | The event to listen to. |
callback | Callback | The 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
Parameter | Type | Description |
---|---|---|
name | string | Unique name of the device to remove. |
Returns
void
removeImage()
removeImage(
name
):void
Removes the specified image from the stream.
Parameters
Parameter | Type | Description |
---|---|---|
name | string | Unique name of the image to remove. |
Returns
void
removeVideoInputDevice()
removeVideoInputDevice(
name
):void
Removes the specified video-input device from the stream.
Parameters
Parameter | Type | Description |
---|---|---|
name | string | unique name of the device to remove. |
Returns
void
startBroadcast()
startBroadcast(
streamKey
,ingestEndpoint
?):Promise
<void
|BroadcastClientError
>
Starts broadcasting to IVS.
Parameters
Parameter | Type | Description |
---|---|---|
streamKey | string | IVS-generated stream key for your IVS channel. |
ingestEndpoint ? | string | IVS-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
Parameter | Type | Description |
---|---|---|
name | string | Unique name of the device to update. |
composition | VideoComposition | The new position. |
Returns
void