Skip to content

Commit

Permalink
[v1.1.0-dev] styling fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Lindsay-Needs-Sleep committed Oct 23, 2020
1 parent 98edc9e commit e823585
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 25 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ The most significant usage difference between the [cast API](https://developers.
In **Chrome desktop** you would do:
```js
window['__onGCastApiAvailable'] = function(isAvailable, err) {
if (isAvailable) {
// start using the api!
}
if (isAvailable) {
// start using the api!
}
};
```

But in **cordova-plugin-chromecast** you do:
```js
document.addEventListener("deviceready", function () {
// start using the api!
// start using the api!
});
```

Expand Down Expand Up @@ -103,11 +103,11 @@ To make your own **custom route selector** use this:
```js
// This will begin an active scan for routes
chrome.cast.cordova.scanForRoutes(function (routes) {
// Here is where you should update your route selector view with the current routes
// This will called each time the routes change
// routes is an array of "Route" objects (see below)
// Here is where you should update your route selector view with the current routes
// This will called each time the routes change
// routes is an array of "Route" objects (see below)
}, function (err) {
// Will return with err.code === chrome.cast.ErrorCode.CANCEL when the scan has been ended
// Will return with err.code === chrome.cast.ErrorCode.CANCEL when the scan has been ended
});

// When the user selects a route
Expand All @@ -116,9 +116,9 @@ chrome.cast.cordova.stopScan();

// and use the selected route.id to join the route
chrome.cast.cordova.selectRoute(route.id, function (session) {
// Save the session for your use
// Save the session for your use
}, function (err) {
// Failed to connect to the route
// Failed to connect to the route
});

```
Expand Down
26 changes: 16 additions & 10 deletions doc/example.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
document.addEventListener("deviceready", function () {
document.addEventListener('deviceready', function () {
// Must wait for deviceready before using chromecast

var chrome = window.chrome;

// File globals
var _session;
var _media;
Expand All @@ -14,14 +16,14 @@ document.addEventListener("deviceready", function () {
// The session listener is only called under the following conditions:
// * will be called shortly chrome.cast.initialize is run
// * if the device is already connected to a cast session
// Basically, this is what allows you to re-use the same cast session
// Basically, this is what allows you to re-use the same cast session
// across different pages and after app restarts
}, function receiverListener (receiverAvailable) {
}, function receiverListener (receiverAvailable) {
// receiverAvailable is a boolean.
// True = at least one chromecast device is available
// False = No chromecast devices available
// You can use this to determine if you want to show your chromecast icon
});
});

// initialize chromecast, this must be done before using other chromecast features
chrome.cast.initialize(apiConfig, function () {
Expand All @@ -30,22 +32,23 @@ document.addEventListener("deviceready", function () {
requestSession();
}, function (err) {
// Initialize failure
console.log(err);
});
}


function requestSession () {
// This will open a native dialog that will let
// This will open a native dialog that will let
// the user choose a chromecast to connect to
// (Or will let you disconnect if you are already connected)
chrome.cast.requestSession(function (session) {
// Got a session!
_session = session;

// Load a video
// Load a video
loadMedia();
}, function (err) {
// Failed, or if err is cancel, the dialog closed
console.log(err);
});
}

Expand All @@ -66,21 +69,23 @@ document.addEventListener("deviceready", function () {

}, function (err) {
// Failed (check that the video works in your browser)
console.log(err);
});
}

function pauseMedia () {
_media.pause({}, function () {
// Success

// Wait a couple seconds
setTimeout(function () {
// stop the session
stopSession();
}, 2000)
}, 2000);

}, function (err) {
// Fail
console.log(err);
});
}

Expand All @@ -90,7 +95,8 @@ document.addEventListener("deviceready", function () {
// Success
}, function (err) {
// Fail
console.log(err);
});
}

});
});
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
"name": "cordova-plugin-chromecast",
"version": "1.0.0",
"version": "1.1.0-dev",
"scripts": {
"host-chrome-tests": "node tests/www/chrome/host-tests.js",
"style-fix-js": "node node_modules/eslint/bin/eslint --fix src && node node_modules/eslint/bin/eslint --fix www && node node_modules/eslint/bin/eslint --ignore-pattern tests/www/lib --fix tests/www",
"test": "node node_modules/eslint/bin/eslint src && node node_modules/eslint/bin/eslint www && node node_modules/eslint/bin/eslint --ignore-pattern tests/www/lib tests/www && node ./node_modules/java-checkstyle/bin/index.js ./src/android/ -c ./check_style.xml",
"style": "npm run style-fix-js && npm run test"
"style-js": "npx eslint --ignore-pattern tests/www/lib www tests/www doc/example.js",
"style-js-fix": "npx eslint --ignore-pattern tests/www/lib/ --fix www/ tests/www/ doc/example.js",
"style-java": "npx java-checkstyle -c ./check_style.xml ./src/android/",
"style": "npm run style-js-fix && npm run style-java",
"test": "npm run style-js && npm run style-java"
},
"author": "",
"license": "dual GPLv3/MPLv2",
Expand All @@ -20,7 +22,7 @@
"eslint-plugin-promise": "~3.5.0",
"eslint-plugin-standard": "~3.0.1",
"express": "^4.17.1",
"java-checkstyle": "0.0.1",
"java-checkstyle": "0.1.0",
"path": "^0.12.7"
}
}

0 comments on commit e823585

Please sign in to comment.