AloAudio

Constructor

There are a number of properties available when instantiating the AloAudio class:

Class Instantiation Properties

In order to instantiate the AloAudio object you are required to provide a number of properties. Below are the properties that are available:

Property

Required

Default

Description

user

Yes

userAuthToken

Yes

ttsEnabled

No

false

Set this to true if you want users in the channel to hear TTS audio.

audioInputDeviceId

No

audioOutputDeviceId

No

Example Properties:

let audioProps = {
    user: user,
    aloConnections: aloConnections,
    ttsEnabled: true
};

Instantiating AloAudio

Once you have defined the properties you instantiate as shown:

const aloAudio = new AloAudio(props);

Methods

connect(channel)

Connects the user to a channel in the Audio Service. See Connect to a Channel.

Parameter

Type

Description

channel

Defines the channel to connect to in the Audio Service

Example:

aloAudio.connect(audioChannel);

changeAudioInput(deviceId)

You can use this method to change the active microphone after connecting to a channel. See Microphone Selection.

Parameter

Type

Description

deviceId

String

changeAudioOutput(deviceId)

You can use this method to change the active speaker after connecting to a channel. See Speaker Selection.

Parameter

Type

Description

deviceId

String

disconnect()

Use this method to disconnect from the Audio Service. See Disconnecting Audio Service.

Event

Description

onDisconnect

Once disconnected, either intentionally or due to an error, the onDisconnect event will be dispatched.

forceReconnectWhenPending()

If the connection to the service has been lost and you do not want to wait for the service to automatically try reconnecting you can call this method and an attempt will be made to reconnect immediately.

fullDuplexMute()

Call this method to mute the microphone when you are in a Full Duplex channel.

fullDuplexToggleMute()

Call this method to toggle the microphone on/off when you are in a Full Duplex channel.

fullDuplexUnmute()

Call this method to unmute the microphone when you are in a Full Duplex channel.

getMediaList()

This method will return the list of available audio input and output devices. See Input/Output Device Selection.

pttEnd()

This method will release the PTT lock for the given channel (if the current user is currently the owner of the lock). Then the microphone will be disabled. See Push To Talk (PTT) for more information.

pttStart()

This method will try to acquire the PTT lock for the currently connected channel. If the lock is acquired the user's microphone will be enabled. See Push To Talk (PTT) for more information.

setUserAuthToken(token)

If the user's authentication token expires you will receive a onInvalidAuthenticationToken event. When you receive the event you must generate a new token and call setUserAuthToken with the new token. Then you must call the connect() method to reconnect.

Parameter

Type

Description

token

String

Last updated

Logo

© Copyright 2024 ALO.ai, Inc. • All Rights Reserved