• English
  • Français

Class Apideo


public class Apideo
The Apideo object is the first object used by any Apideo application. Using it's connect function, you will connect to the Apideo servers.
Defined in apideo.js

Function Summary
public static ApideoConnection connect (string key)
Connects to Apideo, using your Apideo Key.
public boolean hasCamera()
Returns true if there is at least one webcam connected to this computer, false otherwise.
public boolean hasMicrophone()
Returns true if there is at least one microphone connected to this computer, false otherwise.
public static void onDomReady (Object fn)
This function will register a listener that will be called as soon as the DOM is ready.
public void onError (Object callback)
Registers a callback function that will be called if an error occurs in Apideo.
public onReady (Object fn)
Registers a callback called when Apideo is ready to connect to rooms.
public void unregisterOnError (Object callback)
Unregisters a callback function that is called when an uncatched error occurs in Apideo.

Function Details

function connect

public static ApideoConnection connect(string key)
Connects to Apideo, using your Apideo Key. Your Apideo Key is the 18 characters key that has been sent to you when you subscribed to the Apideo service. The call will return an ApideoConnection object.
Parameters:
key - Your Apideo key.
Returns:
The ApideoConnection object you will use to connect to a room.

function hasCamera

public boolean hasCamera()
Returns true if there is at least one webcam connected to this computer, false otherwise.

This function returns true if a webcam is available on the user's computer.

In order to call this function, Apideo must first be ready to handle requests. Therefore, you should never call this function before the Apideo.onReady event is triggered.

Typically, some code to detect the availability of a camera should look like this:

 conn = Apideo.connect("XXXXXXXXXXXXXXXXXX")
 Apideo.onReady(function() {
 	if (!Apideo.hasCamera()) {
 		alert("Sorry, no webcam detected");
  }
 });
 
Returns:
True if the user has at least one webcam connected to its computer. False otherwise.

function hasMicrophone

public boolean hasMicrophone()
Returns true if there is at least one microphone connected to this computer, false otherwise.

This function returns true if a microphone is available on the user's computer.

In order to call this function, Apideo must first be ready to handle requests. Therefore, you should never call this function before the Apideo.onReady event is triggered.

Typically, some code to detect the availability of a camera should look like this:

 conn = Apideo.connect("XXXXXXXXXXXXXXXXXX")
 Apideo.onLoad(function() {
 	if (!Apideo.hasMicrophone()) {
 		alert("Sorry, no microphone detected");
  }
 });
 
Returns:
True if the user has at least one microphone connected to its computer. False otherwise.

function onDomReady

public static void onDomReady(Object fn)
This function will register a listener that will be called as soon as the DOM is ready. It maps the behavious of the jQuery(document).ready() function.
Parameters:
fn

function onError

public void onError(Object callback)
Registers a callback function that will be called if an error occurs in Apideo.

The event handler will catch any error that has not been catched by more specialized event handlers (for instance, by room error event handlers, camera error event handlers or viewers error event handlers).

For more specialized error event handlers, please see ApideoRoom.onError, ApideoCamera.onError and ApideoViewer.onError functions.

Please note that if there is no default event handler, Apideo will provide a default one: a simple alert box will be displayed. As soon as you define one event handler, the default event handler is discarded.

Example usage:

 Apideo.onError(function(category, type, msg) {
 		... your code goes here ...
 });
 

The parameters passed to the callback function are:

  • category {string} - The category of the error.
  • type {string} - The technical type of the error.
  • msg {string} - The message of the error.

The most important parameter is the category. It can be one of:

  • connect - An error occured while connecting to the room.
  • disconnect - An connection error occured: the room has been disconnected.
  • error - An internal error occured.
  • server - An error occured on the server-side.
  • camera - An error occured with a camera started in this room. This kind of error is thrown only if no event handler is attached to the camera.
  • viewer - An error occured with a stream viewed in this room. This kind of error is thrown only if no event handler is attached to the stream played.
Parameters:
callback

function onReady

public onReady(Object fn)
Registers a callback called when Apideo is ready to connect to rooms. This callback will be called once, just after the first Apideo.connect() call succeeds. Once this callback is called, Apideo has successfully loaded the Flash file used to connect to the servers. It means you can safely use functions like "Apideo.hasMicrophone()" or "Apideo.hasCamera()".
Parameters:
fn

function unregisterOnError

public void unregisterOnError(Object callback)
Unregisters a callback function that is called when an uncatched error occurs in Apideo.
Parameters:
callback