This project introduces support for GoogeCast to allow your applications to connect and interact with Chromecast enabled devices.
This project is in active development and currently targets iOS. Android is on the roadmap.
// reference the module
var Chromecast = require('com.atticoos.titanium.chromecast');
// create an instance of the device manager
var deviceManager = Chromecast.createDeviceManager({
app: "APP_ID" // required
});
// listen for new devices
deviceManager.addEventListener('deviceOnline', function (e) {
var device = e.device;
//connect to device
if (!deviceManager.isConnected()) {
device.connect(function () {
device.startApplication(function () {
device.sendJsonMessage({foo: 'bar'});
});
});
}
});
This module provides a few primary components that provide an API to the GoogleCast SDK. This API is not a 1-1 mapping to all the SDK endpoints, it's more of an abstraction to provide easier integrations. While all the capabilities of the SDK are available, they are exposed in different ways.
The device manager oversees all the devices and manages your connectivity to the Chromecast. It provides an interface to the Chromecast for the devices to use. For interacting with the Chromecast directly, you will use the device, but you can still go back to the DeviceManager if necessary.
Returns: void
This begins the scanning service to look for nearby devices
Returns: void
Stops the scanning service
Returns: Array
Returns a collection of discovered Devices.
Returns: Boolean
Returns true/false if there is a device currently connected
Returns: Device
Default: null
Returns the device that is currently connected, otherwise null
Returns: Boolean
Default: false
Returns true/false depending on if the scanner is running
Returns: Boolean
Default: false
Returns true/false depending on if there is a connected device
Returns: Boolean
Default: false
Returns true/false depending on if the application is connected
Returns: String
Default: null
Returns the sessionID of the connected application
Returns: String
Default: null
Returns the status text of the connected application
Called when a device is discovered
Called when a device that was discovered appears offline
This is the device component that returns the information about the current device and an API to interact with the device
Returns: void
Connects to a device and executes the callback once connected or encounters an error
Returns: void
Starts the application on a device and executes the callback once connected or encounters an error
Returns: void
Creates a channel over the provided namespace on the device
Returns: void
Removes a channel that was previously added, otherwise does nothing
Returns: void
Sends a message over the channel to the chromecast app
Returns: void
Sends a JSON object as a message
Returns: Boolean
Default: false
Returns true/false if this device is connected
Returns: Boolean
Default: false
returns true/false if this device is connected to the application on the chromecast
Called when receiving a message over the device's channel