Class: Stream

Stream

Stream

Extends

Methods


<static> createScreensharingStream(captureSourceType)

Helper function to create a new screensharing stream
The feature works both on Firefox and Chrome
On Chrome, the Apizee screensharing extention needs to be installed beforehand

Parameters:
Name Type Description
captureSourceType Object

This enables to choose what the user will be propose to share between screen, applications, browser tab and audio.
Usage is different depending the browser :
-on Chrome, captureSourceTypevalue value is an array that can be ["screen", "window", "tab", "audio"]. This array is used to restrict what will be proposed to the user
-on Firefox, captureSourceTypevalue value is a string that can be "screen", "window" or "application". This string is used to choose what will be proposed to the user

Returns:

Created stream in promise

Type
Promise.<Stream>

<static> createStreamFromMediaStream(mediaStream)

Helper function to create a new stream using an existing mediaStream

Parameters:
Name Type Description
mediaStream MediaStream

mediaStream to use to create a Stream

Returns:

Created stream in promise

Type
Promise.<Stream>

<static> createStreamFromUserMedia(audioInput, videoInput, constraints)

Helper function to create a new stream using user's video & audio sources

Parameters:
Name Type Description
audioInput MediaDevice

audioInput device id, can be null. set to false if audio track is not requested

videoInput MediaDevice

videoInput device id, can be null. set to false if video track is not requested

constraints object

other MediaTrackConstraints that can be specified for stream

Returns:

Created stream in promise

Type
Promise.<Stream>

<static> getAvailableEvents()

Returns available events for this class

Returns:
Type
Array.<string>

<static> getLocalStreams()

Returns local streams list

Returns:

local streams list

Type
Array.<Stream>

<static> getStream(streamId)

Returns local stream with its identifier

Parameters:
Name Type Description
streamId String
Returns:

stream

Type
Stream

addInDiv(divId, mediaEltId, style, muted)

Add stream to DIV elementz

Parameters:
Name Type Description
divId String

Div Id where to add the stream

mediaEltId String

Id of the media element that will be added in the div

style String

Json string with format {width : "160px", height : "120px"} to define width and height of the media element

muted Boolean

Boolean to set if media element is muted or not

Returns:
Type
void

attachToElement(element)

Attaches stream to video DOM element

Parameters:
Name Type Description
element HTMLElement
Returns:
Type
void

disableAudioAnalysis()

Disables audio analysis of Stream
The Stream#audioAmplitude event will no longer be emitted

Returns:
Type
void

enableAudioAnalysis()

Enables audio analysis of Stream
This allows the Stream#audioAmplitude event to be emitted

Returns:
Type
void

getContact()

Gets the stream's owner, returns null if the stream is local

Returns:
Type
Contact

getConversations()

Returns conversations the stream is published in

Returns:
Type
Array.<Conversation>

getData()

Gets the stream's MediaStream object, returns null if the stream has no data

Returns:
Type
MediaStream

getId()

Returns stream id

Returns:

Stream id

Type
string

getOwner()

Returns the owner of the stream reprensented by this one.

Returns:
Type
UserAgent | Contact

getType()

Returns this stream's type

Returns:

type

Type
String

hasAudio()

Checks if stream has at least one audio track

Returns:
Type
boolean

hasData()

Checks if stream has mediastream tracks or data

Returns:
Type
boolean

hasVideo()

Checks if stream has at least one video track

Returns:
Type
boolean

isAudioMuted()

Returns whether the audio track in muted.

Returns:

true if the audio track is muted, false otherwise.

Type
boolean

isScreensharing()

Checks if stream is a screenshare

Returns:
Type
boolean

isVideoMuted()

Returns whether the video track in muted.

Returns:

true if the video track is muted, false otherwise.

Type
boolean

muteAudio()

Mutes this stream's audio
If this stream is published to another contact, the stream will also be muted on the contact's side
If this stream is subscribed from another contact, muting the stream will have no impact on the contact's side

Returns:
Type
Void

muteVideo()

Mutes this stream's video
If this stream is published to another contact, the stream will also be muted on the contact's side
If this stream is subscribed from another contact, muting the stream will have no impact on the contact's side

Returns:
Type
Void

on(listener)

Adds a listener to a Observable event

Parameters:
Name Type Description
listener function
Inherited From:
Returns:

this instance for chaining

Type
Observable

pauseRecord()

Pause the recording of the stream with a promise

Returns:
Type
Promise.<void>

release()

Release all tracks (either video or audio) used by this stream

Returns:
Type
Void

removeFromDiv(divId, mediaEltId)

Remove stream from DIV element

Parameters:
Name Type Description
divId String

Div Id where to add the stream

mediaEltId String

Id of the media element that will be added in the div

Returns:
Type
void

removeListener(eventType, listener)

Remove existing listener to Observable event

Parameters:
Name Type Description
eventType String
listener function
Inherited From:
Returns:

this instance for chaining

Type
Observable

resumeRecord()

Resume the recording of the stream with a promise

Returns:
Type
Promise.<void>

startRecord(options)

Starts the recording of the stream with a promise
The stream is recorded locally
The stream can only have one record process active at a time

Parameters:
Name Type Description
options MediaRecorderOptions
Returns:
Type
Promise.<void>

stopRecord()

Stops the recording of the stream with a promise

Returns:

Blob of the recorded stream in promise

Type
Promise.<Blob>

takeSnapshot(options)

Takes a dataURI/png snapshot from stream

Parameters:
Name Type Description
options SnapshotOptions
Returns:

media PNG dataURI in promise

Type
Promise.<string>

unmuteAudio()

Unmutes this stream's audio
If this stream is published to another contact, the stream will also be unmuted on the contact's side
If this stream is subscribed from another contact, unmuting the stream will have no impact on the contact's side, moreover, it will not unmute the stream if it has been muted by the contact

Returns:
Type
Void

unmuteVideo()

Unmutes this stream's video
If this stream is published to another contact, the stream will also be unmuted on the contact's side
If this stream is subscribed from another contact, muting the stream will have no impact on the contact's side, moreover, it will not unmute the stream if it has been muted by the contact

Returns:
Type
Void

Events


activeStateChange

Emitted when stream video or audio active state changed

Type: object
Properties:
Name Type Description
streamId number

stream identifier.

callId callId

identifier of related call.

type string

'video' or 'audio'

active boolean

new state


audioAmplitude

Stream current audio amplitude obtained from audio analysis

Type: number

muteStateChange

Emitted when stream video or audio mute state changed

Type: object
Properties:
Name Type Description
streamId number

stream identifier.

userMediaStreamId string

user media stream identifier (optional).

callId string

related call identifier (optional).

type string

'video' or 'audio'

muted boolean

new state


stopped

Emitted when user media is released or when related call is terminated.

Type: object
Properties:
Name Type Description
streamId number

stream identifier.

userMediaStreamId string

user media stream identifier (optional).

callId string

related call identifier (optional).


trackStopped

Signals a stream track was stopped (known issue: does not work on Firefox)

Type: object
Properties:
Name Type Description
type string

'video' or 'audio'

id string

track id