A library that unifies both android and iOS chromecast sdk
$ npm install react-native-google-cast --save
Mostly automatic installation
$ react-native link react-native-google-cast
- In XCode, in the project navigator, right click
Add Files to [your project's name]
- Go to
- In XCode, in the project navigator, select your project. Add
libRNGoogleCast.ato your project's
Link Binary With Libraries
- Run your project (
- Open up
import com.reactlibrary.RNGoogleCastPackage;to the imports at the top of the file
new RNGoogleCastPackage()to the list returned by the
- Append the following lines to
include ':react-native-google-cast' project(':react-native-google-cast').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-google-cast/android')
- Insert the following lines inside the dependencies block in
iOS Heads Up
- This library requires Cocoapods to manage Chromecast SDK.
pod 'google-cast-sdk'to your Podfile. This is the easier way to have the SDK up to date.
Android Heads Up
- This library requires Google Play Services to manage Chromecast SDK.
// Require the module;// Init Chromecast SDK and starts looking for devices (uses DEFAULT APP ID)Chromecast;// Init Chromecast SDK and starts looking for devices using registered APP IDChromecast;// Does what the method says. It saves resources, use it when leaving your current viewChromecast;// Returns a boolean with the resultChromecast;// Return an array of devices' names and idsChromecast;// Gets the device id, and connects to it. If it is successful, will send a broadcastChromecast;// Closes the connection to the current ChromecastChromecast;// Streams the media to the connected chromecast. Time parameter let you choose// in which time frame the media should start streamingChromecast;// Move the streaming media to the selected time frameChromecast;// Toggle Chromecast between pause or play stateChromecast;// Get the current streaming time frame. It can be use to sync the chromecast to// your visual media controllersChromecast;
Chromecast uses events to let you know when you should start playing with the service, like streaming the media.
// To know if there are chromecasts aroundDeviceEventEmitter;// To know if the connection attempt was successfulDeviceEventEmitter;// If chromecast started to stream the media succesfully, it will send this eventDeviceEventEmitter;
Refer to the example folder to find an implementation of this project. Remember to use
react-native link react-native-google-cast
to try it!
Contributions are welcome !