LogoLogo
ALO.ai
Developer Documentation
Developer Documentation
  • Developer Documentation
  • Developer Account
    • API Key
  • SDKs
    • Authentication
    • Chat
      • Configuration
      • Send Messages
        • Upload Files
      • Message History
      • Message Actions
      • Message Counts
      • Translation
      • Typing Indicators
      • API Reference
        • Event
        • Message
    • Presence
      • Configuration
      • Basic Usage
      • Methods
    • Audio
      • Prerequisites
      • Instantiating Audio Service
      • Connect to a Channel
      • Disconnecting Audio Service
      • Push To Talk (PTT)
      • Full Duplex
      • Mute and Unmute Audio
      • Input/Output Device Selection
        • Microphone Selection
        • Speaker Selection
      • Channel Participants
      • Text To Speech Audio (TTS)
      • Automatic Reconnects
      • Handling Events
      • Classes
        • AloAudio
        • AudioUser
        • AudioChannel
        • Participant
    • Video
      • Prerequisites
      • Instantiating Video Service
      • Connect to a Channel
      • Disconnecting Video Service
      • Input Device Selection
        • Microphone Selection
        • Camera Selection
      • Publishing Streams
      • Modifying Published Streams
      • Channel Participants
      • Rendering Streams
        • Local Stream
        • Remote Streams
      • Muting/Unmuting Remote Streams
      • Recording Video (coming soon)
      • Automatic Reconnects
      • Handling Events
      • Classes
        • AloVideo
        • Participant
        • VideoChannel
        • VideoUser
  • ALO APPS
    • Overview
    • Creating Apps
    • Webhooks
      • Verifying Requests from ALO
    • Custom Action Forms
    • Using the ALO Platform API
  • ALO Platform API
    • Overview
    • Authentication
    • API
      • Actions and Periods
      • Channels
      • Channel Messages
      • Channel Users
      • Direct Message Channels
      • Direct Message Channel Chat Messages
      • Direct Message Channel Users
      • Groups
      • Periods
      • Types
      • Users
      • Video Management System
  • Misc
    • Supported Language Codes
Powered by GitBook
LogoLogo

ALO.ai

  • ALO.ai

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

On this page
  • AloVideo Properties
  • AloVideo Class
  • Connection Events
  • Sample Instantiation with Event Listeners
  • Sample onConnectionChange Payloads
  1. SDKs
  2. Video

Instantiating Video Service

PreviousPrerequisitesNextConnect to a Channel

Last updated 8 months ago

AloVideo Properties

In order to instantiate the AloVideo object you are required to provide a number of properties. See

AloVideo Class

Once you have defined the properties you instantiate as shown:

aloVideo = new AloVideo(props);

Connection Events

Once instantiated, and , the user will be connected to the AloAudio Service. There are a number of event fire that are related to this connection:

Event

Description

onConnectionChange

As the connection to the Video Service is established events showing the following statuses will be dispatched:

AloVideo.CONNECTION_STATUS_ACQUIRING_ACCESS, AloVideo.CONNECTION_STATUS_CONNECTING, AloVideo.CONNECTION_STATUS_CONNECTED, AloVideo.STATUS_NOT_CONNECTED, AloVideo.CONNECTION_STATUS_ERROR, AloVideo.CONNECTION_STATUS_CONNECTED, AloVideo.CONNECTION_STATUS_RECONNECT_PENDING.

onDisconnect

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

After you instantiate AloVideo you can add event listeners for the events mentioned above.

Sample Instantiation with Event Listeners

function connectToVideo() {    
    const user = new VideoUser (
      "12345",
      {        
        name: "James Jones",
        deviceId: "abcd-efsg-wqer-qewe"
      }
    );
    const props = {
      user: user,
      userAuthToken: "token generated from Authentication Service"
    };
    aloVideo = new AloVideo(props);
    initializeEventListeners();
}

function initializeEventListeners() {
    aloVideo.events.addEventListener('onDisconnect', e => {
      console.log("onDisconnect:", e.detail);
    })

    aloVideo.events.addEventListener('onConnectionChange', action(e => {
      console.log("onConnectionChange:", e.detail);

      switch (e.detail.state) {
        case aloVideo.CONNECTION_STATUS_CONNECTED:
          console.log("Ālo video connected");
          break;
        case aloVideo.CONNECTION_STATUS_DISCONNECTED:
          console.log("Ālo video disconnected");
          break;
        case aloVideo.CONNECTION_STATUS_ERROR:
          console.log("Ālo video connection error", e.detail);
          break;
        case aloVideo.CONNECTION_STATUS_CONNECTING:
          console.log("Ālo video connecting");
          break;
        case aloVideo.CONNECTION_STATUS_RECONNECT_PENDING:
          console.log(
            "Ālo video reconnect pending.  Retrying in ", 
            e.detail.pendingRestartSeconds
          );
          break;
      }

    }));
}

Sample onConnectionChange Payloads

{
 detail: {state: "ACQUIRING_ACCESS"}
}

{
 detail: {state: "CONNECTING"}
}

{
 detail: {
  state: "CONNECTED",
  user: {...}
 }
}

{
 detail: {
  state: "DISCONNECTED",
  user: {...}
 }
}

{
 detail: {
  state: "ERROR",
  message: "Lost connection to the server",
  user: {...}
 }
}
connected to a channel
Class Instantiation Properties