ColorTV Receiver SDK
The ColorTV Receiver SDK is a JavaScript library for Custom Receiver Chromecast applications that enables developers to monetize their apps.
Installation
To install the stable version:
npm install --save colortv-receiver-sdk
This assumes you are using npm as your package manager. If you don't, you can get SDK from here.
Placements
All placements are available in the window.ColorTVSDK object :
- VIDEO
- INTERSTITIAL
- FULL_SCREEN
- APP_WALL
- CONTENT
Example
You can run our example in your browser. In order to run this file, you need two things:
- appId from dashboard
- User-Agent switcher for your browser
Firstly, set your appId in example file. Secondly install user-aget switcher in your browser. For Chrome, we advise user-agent switcher plugin Remember to disable AdBlock.
Below you can find example user-agent that should be set in user-agent switcher.
Mozilla/5.0 (X11; Linux armv7l) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36 CrKey/1.19a.63621
<!-- In order to run this example in your browser, you need to change your user agent to fit connected-tv. --><!-- For Chrome browser, we advise user-agent switcher plugin: https://chrome.google.com/webstore/detail/user-agent-switcher-for-c/djflhoibgkdhkhhcedjiklpkjnoahfmg --><!-- Below is example user-agent that you should set in user-agent switcher --><!-- Mozilla/5.0 (X11; Linux armv7l) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36 CrKey/1.19a.63621 --><!-- Also remember to disable AdBlock --> Chromecast Demo Application <!-- You need to specify the DOM element where you want to show ads. It must be the first child of the body tag. -->/*** You have multiple ways to include our SDK. For this example, script needs to be here due to event listener that we need to setup.*/
The Google Cast SDK and ColoTV Receiver SDK must be included in your project. The SDK can be used in two ways: you can get it from the window object or it can be imported as a module. Next the SDK needs to be initialized. An appID is generated in our dashboard dashboard and is used to identify your app.
The SDK must be initialized before you start castManger because of the additional channels Colortv Sender SDK communicates with the Receiver App on. You may append your callback to any of the core functions of the SDK: init, loadAd and showAd
In order to optimize the user experience we ask that you pause your application when launching our SDK, because if something happens during the ad the user will only be able to react by closing the SDK.
In the following example Promises are used for callbacks.
The callback takes the parameters object as first argument and the second argument can be used for you to pass the function that will be fired as soon as the SDK function is complete.
The callback function takes the error object as the first parameter ( error-first style).
Example:
Callback
var params = placement: ColorTVSDKPlacementsInterstitialvar { iferror // handle error return // continue script}colortv
javascript var params = { placement: ColorTVSDK.Placements.Interstitial } colortv.loadAd(params).then(function(){ //success }).catch(function(error){ if(error){ // handle error return }})
Events
var params = placement: ColorTVSDKPlacementsInterstitialcolortv
Events var params = placement: ColorTVSDKPlacementsInterstitial windowColorTVSDKEventManager colortv
Promisejavascript var params = { placement: ColorTVSDK.Placements.Interstitial } colortv.loadAd(params).then(function(){ //success }).catch(function(error){ if(error){ // handle error return }})
Events
var params = placement: ColorTVSDKPlacementsInterstitialcolortv
Events
var params = placement: ColorTVSDKPlacementsInterstitial windowColorTVSDKEventManager colortv