Introduction
In this section you will learn everything about how THEOplayer works with Chromecast.
API
As a developer, you might need to use the THEOplayer Chromecast API to build a custom Chromecast UI and UX, or to dispatch an event to an analytics service, or for workflow purposes.
The Chromecast interface is a sub-interface of the Cast interface on THEOplayer Web and on both mobile (Android & iOS) SDKs.
The API reference is available through the following links:
- Web SDK: Chromecast, which inherits from VendorCast
- Android SDK: Chromecast
- iOS SDK: Chromecast
Use the API as demonstrated below:
THEOplayer Web SDK
// const player = new THEOplayer.Player(...)
const chromecastState = player.cast.chromecast.state;
const isCasting = player.cast.chromecast.casting; // true or false
// ...
// if (want to start Chromecast)
player.cast.chromecast.start();
// ...
// if (want to stop Chromecast)
player.cast.chromecast.stop();
// ...
if (chromecastState != "unavailable") {
// Chromecast is possible
player.cast.chromecast.addEventListener("statechange", function (event) {
switch (event.state) {
case "connecting":
// show Chromecast trying-to-connect icon
break;
case "available":
// show Chromecast available icon
break;
case "connected":
// show Chromecast connected icon
break;
case "unavailable":
// hide Chromecast icon
break;
}
});
}