Cast API

The Cast object has the following APIs available for casting on external devices:

  • Chromecast API
  • Airplay API

Properties

The Cast object provides the following properties:

Property Type Description
casting boolean Indicates whether or not THEOplayer is currently connected with a casting device.
chromecast Chromecast A Chromecast integration object that allows you to cast to a Chromecast and inspect its state.
airplay Airplay An Airplay integration object that allows you to cast to an Airplay-compatible device and inspect its state.


Chromecast API

The Chromecast API helps you configure and control casting to external devices with THEOplayer.

Chromecast, also known as Google Cast, is a casting device designed by Google. THEOplayer has built-in support for this technology. This integration depends on the Cast SDK, so it should be loaded.

Properties

The Chromecast object provides the following properties:

Property Type Description
casting boolean Indicates whether or not THEOplayer is casting to a chromecast and has control over the current chromecast session.
error Error Casting errors can be found here.
receiverName string The name of the chromecast device that THEOplayer is casting to.
This value is null if THEOplayer is not controlling the current chromecast session.
state string Indicates the state of the casting process:
  • Unavailable means that there is no chromecast device detected or that the device is not available (e.g. not powered, not connected to the internet)
  • Available means that there is a chromecast device detected, but that THEOplayer is not casting or controlling the current chromecast session.
  • Connecting means that THEOplayer is in the process of connecting to the chromecast device.
  • Connected means that THEOplayer is casting to the chromecast device.

Methods

The Chromecast object provides the following properties:

Property Arguments Description
addEventListener type : string, listener : EventListener Adds the listener for the given event type.
start   Start casting to the chromecast. The browser will prompt to choose the device.
stop   Stop casting to the chromecast.
removeEventListener type : string, listener : EventListener Removes the listener for the given event type.

Chromecast Events

The Chromecast object exposes the following events:

Event Description
error Thrown to indicate that there was an error while casting / trying to cast.
Contains error property, with more details as following:
  • code
  • description;
  • details
    • reason
    • type
statechange Thrown to indicate that the state of the connection has changed (see property state).
Provides the property state (string), which resembles the new state

 

Airplay API

The Airplay API helps you configure and control casting to external Airplay-compatible devices with THEOplayer.

Airplay is a protocol suite developed by Apple Inc. that allows wireless streaming between Apple devices and Airplay receivers. THEOplayer has built-in support for this technology.

Properties

The Airplayobject provides the following properties:

Property Type Description
casting boolean Indicates whether or not THEOplayer is casting to an Airplay device and has control over the current Airplay session.
available boolean An Airplay device is detected, but THEOplayer is not casting or controlling the current Airplay session.
connected boolean Indicates whether or not THEOplayer is casting to an Airplay-compatible device.
state string Indicates the state of the casting process:
  • Unavailable means that no Airplay-compatible device is detected or that the device is not available (e.g. not powered, not connected to the internet)
  • Available means that an Airplay-compatible device is detected, but that THEOplayer is not casting or controlling the current Airplay session.
  • Connected means that THEOplayer is casting to the Airplay device.

Methods

The Airplay object provides the following properties:

Property Arguments Description
addEventListener type : string, listener : EventListener Adds the listener for the given event type.
start   Start casting to the Airplay-compatible device. The browser will prompt to choose the device.
stop   Stop casting to the Airplay-compatible device.
removeEventListener type : string, listener : EventListener Removes the listener for the given event type.

Airplay Events

The Airplay object exposes the following events:

Event Description
statechange Thrown to indicate that the state of the connection has changed (see property state).
Provides the property state (string), which resembles the new state