dabder / cordova-chromecast-1

Chromecast running in Cordova

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cordova-chromecast

Chromecast in Cordova

This is a fork of https://github.com/c4software/cordova-chromecast-1.git which contains the required files to enable automatic installation from Cordova CLI.

Main fixes :

  • Compatibility with Cordova 7+
  • Fix Google Play library clash
  • Fix session.sendMessage error handling

Installation

For now, add the plugin from this repository, we'll publish soon with more progress.

cordova plugin add https://github.com/dabder/cordova-chromecast-1.git

Example

initialize = function () {
    var appId = 'xxxxxxxx';
    var _session;

    var sessionRequest = new chrome.cast.SessionRequest(appId);

    var receiverListener = function (status) {
        console.log("receiverListener status", status);
    }

    var sessionListener = function (session) {
        _session = session
    }

    var apiConfig = new chrome.cast.ApiConfig(sessionRequest, sessionListener, receiverListener);


    chrome.cast.initialize(apiConfig, function () {

        console.log('initialize success');
        document.getElementById("message").innerHTML = "initialize success";

    }, function (err) {

        console.log('initialize error', err);
        document.getElementById("message").innerHTML = "initialize error";
    });
}


cast = function () {

    chrome.cast.requestSession(
        function () {
            console.log('requestSession success');
        },
        function (err) {
            console.log('requestSession error', err);
        });
}

About

Chromecast running in Cordova


Languages

Language:JavaScript 58.5%Language:Java 41.5%