/ fm / liveswitch / LocalMedia
Class: LocalMedia
fm.liveswitch.LocalMedia
Hierarchy
-
↳ LocalMedia
Implements
Table of contents
Constructors
Properties
Methods
- addOnAudioDestroyed
- addOnAudioLevel
- addOnAudioMuted
- addOnAudioStarted
- addOnAudioStopped
- addOnAudioUnmuted
- addOnDeviceChange
- addOnVideoDestroyed
- addOnVideoMuted
- addOnVideoSize
- addOnVideoSizeChange
- addOnVideoStarted
- addOnVideoStopped
- addOnVideoUnmuted
- changeAudioInput
- changeAudioMediaStream
- changeAudioSourceInput
- changeVideoInput
- changeVideoMediaStream
- changeVideoSourceInput
- destroy
- getAudioEncoding
- getAudioEncodings
- getAudioGain
- getAudioInput
- getAudioInputs
- getAudioLevelInterval
- getAudioMuted
- getAudioSimulcastDisabled
- getAudioSimulcastEncodingCount
- getAudioSimulcastPreferredBitrate
- getAudioSink
- getAudioSourceInput
- getAudioSourceInputs
- getAudioTrack
- getAudioTracks
- getAudioVolume
- getDynamicProperties
- getDynamicValue
- getId
- getState
- getTypeString
- getVideoEncoding
- getVideoEncodings
- getVideoInput
- getVideoInputs
- getVideoMuted
- getVideoSimulcastBitsPerPixel
- getVideoSimulcastDegradationPreference
- getVideoSimulcastDisabled
- getVideoSimulcastEncodingCount
- getVideoSimulcastPreferredBitrate
- getVideoSink
- getVideoSize
- getVideoSourceInput
- getVideoSourceInputs
- getVideoTrack
- getVideoTracks
- getView
- getViewSink
- grabVideoFrame
- removeOnAudioDestroyed
- removeOnAudioLevel
- removeOnAudioMuted
- removeOnAudioStarted
- removeOnAudioStopped
- removeOnAudioUnmuted
- removeOnDeviceChange
- removeOnVideoDestroyed
- removeOnVideoMuted
- removeOnVideoSize
- removeOnVideoSizeChange
- removeOnVideoStarted
- removeOnVideoStopped
- removeOnVideoUnmuted
- setAudioEncodings
- setAudioGain
- setAudioInput
- setAudioLevelInterval
- setAudioMuted
- setAudioSimulcastDisabled
- setAudioSimulcastEncodingCount
- setAudioSimulcastPreferredBitrate
- setAudioSourceInput
- setAudioVolume
- setDynamicValue
- setId
- setVideoEncodings
- setVideoInput
- setVideoMuted
- setVideoSimulcastBitsPerPixel
- setVideoSimulcastDegradationPreference
- setVideoSimulcastDisabled
- setVideoSimulcastEncodingCount
- setVideoSimulcastPreferredBitrate
- setVideoSourceInput
- start
- stop
- unsetDynamicValue
- canScreenShare
- getChromeExtensionId
- getChromeExtensionInstalled
- getChromeExtensionRequiresUserGesture
- getChromeExtensionUrl
- setChromeExtensionId
- setChromeExtensionRequiresUserGesture
Constructors
constructor
+ new LocalMedia(audio
: any, video
: any, screen?
: boolean): LocalMedia
Parameters:
Name | Type |
---|---|
audio |
any |
video |
any |
screen? |
boolean |
Returns: LocalMedia
Inherited from: Media
Defined in: Generated/TypeScript/fm.liveswitch/LocalMedia.ts:211
Properties
_internal
• Private
_internal: IInternalLocalMedia
Defined in: Generated/TypeScript/fm.liveswitch/LocalMedia.ts:12
Methods
addOnAudioDestroyed
▸ addOnAudioDestroyed(value
: IAction0): void
Registers a handler that triggers when the audio track is destroyed.
Parameters:
Name | Type |
---|---|
value |
IAction0 |
Returns: void
Implementation of: IExternalLocalMedia
Inherited from: Media
Defined in: Generated/TypeScript/fm.liveswitch/Media.ts:14
addOnAudioLevel
▸ addOnAudioLevel(value
: IAction1<number>): void
Registers a handler that gives audio level updates for the media. This method can be called before or after the media has started. When the media is in the Started state, the function runs every 100 milliseconds.
Use this method to determine which audio streams are active.
Parameters:
Name | Type |
---|---|
value |
IAction1<number> |
Returns: void
Implementation of: IExternalLocalMedia
Inherited from: Media
Defined in: Generated/TypeScript/fm.liveswitch/Media.ts:43
addOnAudioMuted
▸ addOnAudioMuted(value
: IAction0): void
Parameters:
Name | Type |
---|---|
value |
IAction0 |
Returns: void
Implementation of: IExternalLocalMedia
Defined in: Generated/TypeScript/fm.liveswitch/LocalMedia.ts:18
addOnAudioStarted
▸ addOnAudioStarted(value
: IAction0): void
Registers a handler on this media that’s raised when the audio track is started.
If there are multiple audio tracks in a custom media stack, this method calls into the first audio track.
Parameters:
Name | Type |
---|---|
value |
IAction0 |
Returns: void
Implementation of: IExternalLocalMedia
Defined in: Generated/TypeScript/fm.liveswitch/LocalMedia.ts:47
addOnAudioStopped
▸ addOnAudioStopped(value
: IAction0): void
Registers a handler on this media that’s raised when the audio track is stopped.
If there are multiple audio tracks in a custom media stack, this method calls into the first audio track.
Parameters:
Name | Type |
---|---|
value |
IAction0 |
Returns: void
Implementation of: IExternalLocalMedia
Defined in: Generated/TypeScript/fm.liveswitch/LocalMedia.ts:55
addOnAudioUnmuted
▸ addOnAudioUnmuted(value
: IAction0): void
Parameters:
Name | Type |
---|---|
value |
IAction0 |
Returns: void
Implementation of: IExternalLocalMedia
Defined in: Generated/TypeScript/fm.liveswitch/LocalMedia.ts:21
addOnDeviceChange
▸ addOnDeviceChange(value
: IAction1<any>): void
Registers a handler on this media that’s raised when the available devices change.
Parameters:
Name | Type |
---|---|
value |
IAction1<any> |
Returns: void
Defined in: Generated/TypeScript/fm.liveswitch/LocalMedia.ts:553
addOnVideoDestroyed
▸ addOnVideoDestroyed(value
: IAction0): void
Registers a handler that triggers when the video track is destroyed.
Parameters:
Name | Type |
---|---|
value |
IAction0 |
Returns: void
Implementation of: IExternalLocalMedia
Inherited from: Media
Defined in: Generated/TypeScript/fm.liveswitch/Media.ts:21
addOnVideoMuted
▸ addOnVideoMuted(value
: IAction0): void
Parameters:
Name | Type |
---|---|
value |
IAction0 |
Returns: void
Implementation of: IExternalLocalMedia
Defined in: Generated/TypeScript/fm.liveswitch/LocalMedia.ts:24
addOnVideoSize
▸ addOnVideoSize(value
: IAction1<Size>): void
Registers a handler that provides updates about the media’s video size.
This event can be used to determine when the video size changes.
Parameters:
Name | Type |
---|---|
value |
IAction1<Size> |
Returns: void
Implementation of: IExternalLocalMedia
Inherited from: Media
Defined in: Generated/TypeScript/fm.liveswitch/Media.ts:51
addOnVideoSizeChange
▸ addOnVideoSizeChange(value
: IAction1<Size>): void
Parameters:
Name | Type |
---|---|
value |
IAction1<Size> |
Returns: void
Implementation of: IExternalLocalMedia
Inherited from: Media
Defined in: Generated/TypeScript/fm.liveswitch/Media.ts:54
addOnVideoStarted
▸ addOnVideoStarted(value
: IAction0): void
Registers a handler on this media that’s raised when the video track is started.
If there are multiple video tracks in a custom media stack, this method calls into the first video track.
Parameters:
Name | Type |
---|---|
value |
IAction0 |
Returns: void
Implementation of: IExternalLocalMedia
Defined in: Generated/TypeScript/fm.liveswitch/LocalMedia.ts:63
addOnVideoStopped
▸ addOnVideoStopped(value
: IAction0): void
Registers a handler on this media that’s raised when the video track is stopped.
If there are multiple video tracks in a custom media stack, this method calls into the first video track.
Parameters:
Name | Type |
---|---|
value |
IAction0 |
Returns: void
Implementation of: IExternalLocalMedia
Defined in: Generated/TypeScript/fm.liveswitch/LocalMedia.ts:71
addOnVideoUnmuted
▸ addOnVideoUnmuted(value
: IAction0): void
Parameters:
Name | Type |
---|---|
value |
IAction0 |
Returns: void
Implementation of: IExternalLocalMedia
Defined in: Generated/TypeScript/fm.liveswitch/LocalMedia.ts:27
changeAudioInput
▸ changeAudioInput(audioInput
: SourceInput): Future<Object>
deprecated
Use changeAudioSourceInput instead.
Parameters:
Name | Type |
---|---|
audioInput |
SourceInput |
Returns: Future<Object>
Defined in: Generated/TypeScript/fm.liveswitch/LocalMedia.ts:365
changeAudioMediaStream
▸ changeAudioMediaStream(value
: MediaStream, id
: string, name
: string, stopAudio
: boolean): Future<Object>
Changes the MediaStream of the audio while the media is active.
This accepts the browser's WebRTC MediaStream that may originate from MediaDevices, an HTMLCanvasElement or an HTMLMediaElement.
An optional id and name can be provided for the SourceInput that's created from this stream. If the optional id is not provided, the
device id from the audio track settings will be used if available, or the id of the Media Stream if not. If the optional name is not
provided the label of the audio track will be used if available, or the id of the Media Stream if not.
Parameters:
Name | Type |
---|---|
value |
MediaStream |
id |
string |
name |
string |
stopAudio |
boolean |
Returns: Future<Object>
Defined in: Generated/TypeScript/fm.liveswitch/LocalMedia.ts:321
changeAudioSourceInput
▸ changeAudioSourceInput(audioSourceInput
: SourceInput): Future<Object>
Changes the audio source input of the audio track while the media is active. If there are multiple audio tracks in a custom media stack, this method calls into the first audio track.
Parameters:
Name | Type |
---|---|
audioSourceInput |
SourceInput |
Returns: Future<Object>
Implementation of: IExternalLocalMedia
Defined in: Generated/TypeScript/fm.liveswitch/LocalMedia.ts:242
changeVideoInput
▸ changeVideoInput(videoInput
: SourceInput): Future<Object>
deprecated
Use changeVideoSourceInput instead.
Parameters:
Name | Type |
---|---|
videoInput |
SourceInput |
Returns: Future<Object>
Defined in: Generated/TypeScript/fm.liveswitch/LocalMedia.ts:372
changeVideoMediaStream
▸ changeVideoMediaStream(value
: MediaStream, id
: string, name
: string, stopVideo
: boolean): Future<Object>
Changes the MediaStream of the video while the media is active.
This accepts the browser's WebRTC MediaStream that may originate from MediaDevices, an HTMLCanvasElement or an HTMLMediaElement.
An optional id and name can be provided for the SourceInput that's created from this stream. If the optional id is not provided, the
device id from the video track settings will be used if available, or the id of the Media Stream if not. If the optional name is not
provided the label of the video track will be used if available, or the id of the Media Stream if not.
Parameters:
Name | Type |
---|---|
value |
MediaStream |
id |
string |
name |
string |
stopVideo |
boolean |
Returns: Future<Object>
Defined in: Generated/TypeScript/fm.liveswitch/LocalMedia.ts:332
changeVideoSourceInput
▸ changeVideoSourceInput(videoSourceInput
: SourceInput): Future<Object>
Changes the video source input of the video track while the media is active. If there are multiple video tracks in a custom media stack, this method calls into the first video track.
This method can be used to change the video source’s input on a mobile device from a front to a back camera.
Parameters:
Name | Type |
---|---|
videoSourceInput |
SourceInput |
Returns: Future<Object>
Implementation of: IExternalLocalMedia
Defined in: Generated/TypeScript/fm.liveswitch/LocalMedia.ts:250
destroy
▸ destroy(): void
Destroys all non-persistent internal objects encapsulated by the Media class.
This method iterates over all audio and video tracks and calls each track's Destroy method for non-persistent tracks.
Returns: void
Implementation of: IExternalLocalMedia
Inherited from: Media
Defined in: Generated/TypeScript/fm.liveswitch/Media.ts:217
getAudioEncoding
▸ getAudioEncoding(): AudioEncodingConfig
Gets the local audio encoding configuration. If there are multiple audio encoding configurations, this method returns the first audio encoding configuration.
Returns: AudioEncodingConfig
Implementation of: IExternalLocalMedia
Defined in: Generated/TypeScript/fm.liveswitch/LocalMedia.ts:110
getAudioEncodings
▸ getAudioEncodings(): AudioEncodingConfig[]
Gets the local audio encoding configurations.
Returns: AudioEncodingConfig[]
Implementation of: IExternalLocalMedia
Defined in: Generated/TypeScript/fm.liveswitch/LocalMedia.ts:117
getAudioGain
▸ getAudioGain(): number
Gets a value indicating the gain (input amplification) of this audio track.
Returns: number
Implementation of: IExternalLocalMedia
Inherited from: Media
Defined in: Generated/TypeScript/fm.liveswitch/Media.ts:61
getAudioInput
▸ getAudioInput(): SourceInput
deprecated
Use getAudioSourceInput instead.
Returns: SourceInput
Defined in: Generated/TypeScript/fm.liveswitch/LocalMedia.ts:379
getAudioInputs
▸ getAudioInputs(): Future<SourceInput[]>
deprecated
Use getAudioSourceInputs instead.
Returns: Future<SourceInput[]>
Defined in: Generated/TypeScript/fm.liveswitch/LocalMedia.ts:386
getAudioLevelInterval
▸ getAudioLevelInterval(): number
Gets the interval in milliseconds between audio level events.
Returns: number
Implementation of: IExternalLocalMedia
Inherited from: Media
Defined in: Generated/TypeScript/fm.liveswitch/Media.ts:68
getAudioMuted
▸ getAudioMuted(): boolean
Checks whether the audio track is muted. Returns true if the audio track is muted and false otherwise. If there are multiple audio tracks in a custom media stack, this method calls into the first audio track.
Returns: boolean
Implementation of: IExternalLocalMedia
Inherited from: Media
Defined in: Generated/TypeScript/fm.liveswitch/Media.ts:75
getAudioSimulcastDisabled
▸ getAudioSimulcastDisabled(): boolean
Checks whether audio simulcast is disabled. Returns true if audio simulcast is disabled and returns false otherwise.
Returns: boolean
Implementation of: IExternalLocalMedia
Defined in: Generated/TypeScript/fm.liveswitch/LocalMedia.ts:428
getAudioSimulcastEncodingCount
▸ getAudioSimulcastEncodingCount(): number
Gets the number of audio simulcast encodings. The number of encodings cannot be changed once they are set.
Returns: number
Implementation of: IExternalLocalMedia
Defined in: Generated/TypeScript/fm.liveswitch/LocalMedia.ts:442
getAudioSimulcastPreferredBitrate
▸ getAudioSimulcastPreferredBitrate(): number
Gets the preferred bitrate for audio simulcast in Kbps.
Returns: number
Implementation of: IExternalLocalMedia
Defined in: Generated/TypeScript/fm.liveswitch/LocalMedia.ts:458
getAudioSink
▸ getAudioSink(): DomAudioSink
Gets the audio sink. An audio sink is where audio leaves the processing pipeline.
An example of an audio sink is a playback device like a speaker.
Returns: DomAudioSink
Implementation of: IExternalLocalMedia
Inherited from: Media
Defined in: Generated/TypeScript/fm.liveswitch/Media.ts:225
getAudioSourceInput
▸ getAudioSourceInput(): SourceInput
Gets the name and ID of the currently available audio device. If there are multiple audio tracks in a custom media stack, this method calls into the first audio track.
A common requirement when working with LiveSwitch is to present the available media device for the user to select from. Additionally, you might want to store the selected device for retrieval. For example, to select the device again if the user leaves and returns.
A device's ID does not have to be guaranteed to be the same between browser sessions. Ensure your code that changes audio inputs reverts to a default if the selected device is unavailable. To do this, pass nothing to the method.
If you have not been granted access to the underlying media, some browsers anonymize the returned data to prevent browser fingerprinting. It is highly recommended that you use this method once you have gained access to the underlying media by prompting the user using localMedia.start()
Returns: SourceInput
Implementation of: IExternalLocalMedia
Defined in: Generated/TypeScript/fm.liveswitch/LocalMedia.ts:260
getAudioSourceInputs
▸ getAudioSourceInputs(): Future<SourceInput[]>
Gets a list of the names and IDs of currently available audio devices.
A common requirement when working with LiveSwitch is to present a list of available media devices for the user to select from. Additionally, you might want to store the selected devices for retrieval. For example, to select the device again if the user leaves and returns.
A device's ID does not have to be guaranteed to be the same between browser sessions. This list can change when devices are added or removed. Ensure your code that changes audio inputs reverts to a default if the selected device is unavailable. To do this, pass nothing to the method.
If you have not been granted access to the underlying media, some browsers anonymize the returned data to prevent browser fingerprinting. It is highly recommended that you use this method once you have gained access to the underlying media by prompting the user using localMedia.start().
Returns: Future<SourceInput[]>
Implementation of: IExternalLocalMedia
Defined in: Generated/TypeScript/fm.liveswitch/LocalMedia.ts:270
getAudioTrack
▸ getAudioTrack(): AudioTrack
Gets the audio track from this media. If there are multiple audio tracks in a custom media stack, this method calls into the first audio track. Returns null if there are no audio tracks.
Returns: AudioTrack
Implementation of: IExternalLocalMedia
Inherited from: Media
Defined in: Generated/TypeScript/fm.liveswitch/Media.ts:82
getAudioTracks
▸ getAudioTracks(): AudioTrack[]
Gets all audio tracks from this media.
Returns: AudioTrack[]
Implementation of: IExternalLocalMedia
Inherited from: Media
Defined in: Generated/TypeScript/fm.liveswitch/Media.ts:89
getAudioVolume
▸ getAudioVolume(): number
Gets a value that indicates the volume (output resistance) of the audio track.
Valid values range between 0.0 and 1.0. A value of 1.0 indicates that there is no output resistance and audio is played at the input level. A value of 0.0 mutes the audio.
If there are multiple audio tracks in a custom media stack, this method calls into the first audio track.
Returns: number
Implementation of: IExternalLocalMedia
Inherited from: Media
Defined in: Generated/TypeScript/fm.liveswitch/Media.ts:98
getDynamicProperties
▸ getDynamicProperties(): Hash<string, Object>
Gets all dynamic properties on this instance.
Returns: Hash<string, Object>
Inherited from: Media
Defined in: Generated/TypeScript/fm.liveswitch/Dynamic.ts:37
getDynamicValue
▸ getDynamicValue(key
: string): Object
Gets a property value from the local cache.
Parameters:
Name | Type | Description |
---|---|---|
key |
string | The property key. This key is used internally only, but should be namespaced to avoid conflict with third-party extensions. |
Returns: Object
The stored value, if found; otherwise null.
Inherited from: Media
Defined in: Generated/TypeScript/fm.liveswitch/Dynamic.ts:58
getId
▸ getId(): string
Gets the unique media identifier.
Returns: string
Implementation of: IExternalLocalMedia
Inherited from: Media
Defined in: Generated/TypeScript/fm.liveswitch/Media.ts:105
getState
▸ getState(): LocalMediaState
Gets the current state of this media. The possible states are defined in the enumeration LocalMediaState. Use this method to check if, for example, the media instance is starting, has started, is stopping, or has stopped.
Returns: LocalMediaState
Implementation of: IExternalLocalMedia
Defined in: Generated/TypeScript/fm.liveswitch/LocalMedia.ts:421
getTypeString
▸ getTypeString(): string
Gets the LocalMedia object type as a string.
Returns: string
Overrides: Media
Defined in: Generated/TypeScript/fm.liveswitch/LocalMedia.ts:8
getVideoEncoding
▸ getVideoEncoding(): VideoEncodingConfig
Gets the local video encoding configuration.
If there are multiple video tracks in a custom media stack, this method calls into the first video track. Returns the local VideoEncodingConfig.
Returns: VideoEncodingConfig
Implementation of: IExternalLocalMedia
Defined in: Generated/TypeScript/fm.liveswitch/LocalMedia.ts:133
getVideoEncodings
▸ getVideoEncodings(): VideoEncodingConfig[]
Gets local video encoding configurations. Returns the array of local VideoEncodingConfig.
Returns: VideoEncodingConfig[]
Implementation of: IExternalLocalMedia
Defined in: Generated/TypeScript/fm.liveswitch/LocalMedia.ts:140
getVideoInput
▸ getVideoInput(): SourceInput
deprecated
Use getVideoSourceInput instead.
Returns: SourceInput
Defined in: Generated/TypeScript/fm.liveswitch/LocalMedia.ts:393
getVideoInputs
▸ getVideoInputs(): Future<SourceInput[]>
deprecated
Use getVideoSourceInputs instead.
Returns: Future<SourceInput[]>
Defined in: Generated/TypeScript/fm.liveswitch/LocalMedia.ts:400
getVideoMuted
▸ getVideoMuted(): boolean
Checks whether the video track is muted. Returns true if the video track is muted and false otherwise.
If the muted video track is part of a local media stack, then all outbound video frames are muted for any participants receiving them. If the muted video track is part of a remote media stack, then inbound video frames are muted and other participants are not affected.
If there are multiple video tracks in a custom media stack, this method calls into the first video track.
Returns: boolean
Implementation of: IExternalLocalMedia
Inherited from: Media
Defined in: Generated/TypeScript/fm.liveswitch/Media.ts:114
getVideoSimulcastBitsPerPixel
▸ getVideoSimulcastBitsPerPixel(): number
Gets the number of bits per pixel (bpp) for a video simulcast.
Returns: number
Implementation of: IExternalLocalMedia
Defined in: Generated/TypeScript/fm.liveswitch/LocalMedia.ts:514
getVideoSimulcastDegradationPreference
▸ getVideoSimulcastDegradationPreference(): VideoDegradationPreference
Gets the video’s simulcast degradation preference.
The following degradation preferences can be set:
Automatic: Prefers to automate degradation based on video type. A Screen video type prefers to degrade FrameRate. A Camera video type prefers to degrade Resolution. An unknown video type prefers a Balanced approach.
Balanced: Prefers to degrade both FrameRate and Resolution together in smaller increments.
FrameRate: Prefers to degrade FrameRate instead of Resolution.
Resolution: Prefers to degrade Resolution instead of FrameRate.
Returns: VideoDegradationPreference
Implementation of: IExternalLocalMedia
Defined in: Generated/TypeScript/fm.liveswitch/LocalMedia.ts:534
getVideoSimulcastDisabled
▸ getVideoSimulcastDisabled(): boolean
Checks whether video simulcast is disabled. Returns true if video simulcast is disabled and returns false otherwise.
Returns: boolean
Implementation of: IExternalLocalMedia
Defined in: Generated/TypeScript/fm.liveswitch/LocalMedia.ts:472
getVideoSimulcastEncodingCount
▸ getVideoSimulcastEncodingCount(): number
Gets the number of video simulcast encodings.
Returns: number
Implementation of: IExternalLocalMedia
Defined in: Generated/TypeScript/fm.liveswitch/LocalMedia.ts:486
getVideoSimulcastPreferredBitrate
▸ getVideoSimulcastPreferredBitrate(): number
Gets the preferred bitrate of an video simulcast in Kbps.
Returns: number
Implementation of: IExternalLocalMedia
Defined in: Generated/TypeScript/fm.liveswitch/LocalMedia.ts:500
getVideoSink
▸ getVideoSink(): DomVideoSink
Gets the video view sink if video is not disabled. ViewSink controls the view which displays the video.
For example, in HTML the