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

The AudioUser that defines the user that is participating in AloAudio.

userAuthToken

Yes

See Generating User Authentication Tokens for information on acquiring this token.

ttsEnabled

No

false

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

audioInputDeviceId

No

This is the id of an audio input device (microphone). When specified, this is the device that will be used for audio input. If no device is specified the operating system's default audio input device will be used. For more information see Microphone Selection.

audioOutputDeviceId

No

This is the id of an audio output device (speakers, headset, etc). When specified, this is the device that will be used for audio output. If no device is specified the operating system's default audio output device will be used. NOTE: This feature is currently only supported within Chrome browsers. For more information see Speaker Selection.

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

This is the id of the microphone to be used. See Microphone Selection.

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

This is the id of the speaker to be used. See Speaker Selection.

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

This is the authentication token needed to access audio rooms. See: Authentication for information about obtaining the token.

Last updated

Logo

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