Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.0.0 Refactor (Issue #36) #54

Merged
merged 174 commits into from
Feb 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
174 commits
Select commit Hold shift + click to select a range
1d06ea3
Update cast library so that it doesn't conflict with the androidx lib…
Sel-en-ium Aug 2, 2019
575195a
Merge branch 'androidx'
Sel-en-ium Aug 2, 2019
455c968
Update cast library so that it doesn't conflict with the androidx lib…
Sel-en-ium Aug 2, 2019
0e65d7f
Merge branch 'gitignore' into eslint
Sel-en-ium Aug 2, 2019
1e5ec66
Move js files to www to follow the standard-ish plugin format
Sel-en-ium Jul 31, 2019
4f2d19d
Add eslint test (so that the code can have a unified [standard-ish] s…
Sel-en-ium Jul 31, 2019
08a0ec0
Satisfy ESLint. (To [commit history], I'm sorry.)
Sel-en-ium Jul 31, 2019
1852f5f
Merge branch 'eslint'
Sel-en-ium Aug 2, 2019
ba79aaf
Updated the jasmine tests to use the newer cordova-plugin-test-framew…
Sel-en-ium Jul 31, 2019
a7a2e52
Switch to MediaRouteChooserDialog to simplify the dialog building pro…
Lindsay-Needs-Sleep Aug 7, 2019
68cc66c
We should not be logging to javascript all the time. It is an abuse …
Lindsay-Needs-Sleep Aug 7, 2019
5218a31
WIP: Got the test framework to run. Basically all the tests are brok…
Lindsay-Needs-Sleep Aug 7, 2019
b1f9587
WIP: Got the first couple tests working.
Lindsay-Needs-Sleep Aug 7, 2019
3fda810
WIP: Got request session somewhat working
Lindsay-Needs-Sleep Aug 26, 2019
d9c59e8
WIP: Add a video that will actually play and fix the load media test
Lindsay-Needs-Sleep Aug 26, 2019
ac1495e
.gitignore update
Lindsay-Needs-Sleep Aug 26, 2019
2941f8c
Got all the tests to pass
Lindsay-Needs-Sleep Aug 26, 2019
f6bb193
Merge remote-tracking branch 'remotes/jellyfin/master'
Lindsay-Needs-Sleep Aug 26, 2019
7812934
remove receiverAvailable because it does nothing
Lindsay-Needs-Sleep Aug 26, 2019
2cda237
Version bump to 1.0.0
Lindsay-Needs-Sleep Aug 26, 2019
b64e836
Should make sure assets are in the plugin folder so that we don't pol…
Lindsay-Needs-Sleep Aug 28, 2019
922908f
reject and catch don't work great because jasmine does not give very …
Lindsay-Needs-Sleep Aug 28, 2019
d4058fe
Update package.json to match licensing
Lindsay-Needs-Sleep Aug 28, 2019
9ae454b
Fix on requestSession cancel handling to match the documentation and …
Lindsay-Needs-Sleep Aug 28, 2019
e9dcf76
Forgot to remove unused references to receiverAvailable related vars.
Lindsay-Needs-Sleep Aug 28, 2019
c921583
Update readme
Lindsay-Needs-Sleep Aug 28, 2019
c0092bf
Integrate receiverListener test into initialize. Having cross-test d…
Lindsay-Needs-Sleep Aug 30, 2019
8a1348d
rename for next commit
Lindsay-Needs-Sleep Sep 5, 2019
a822f61
Update to cast v3 sender to remove deprecated functions.
Lindsay-Needs-Sleep Sep 7, 2019
14f236e
Added a java file style checker that enforces 4 spaces.
Lindsay-Needs-Sleep Sep 9, 2019
8c05c82
Added stop casting dialog.
Lindsay-Needs-Sleep Sep 9, 2019
a5902dd
Apparently my changes for scanning for routes, stopping the scan, and…
Lindsay-Needs-Sleep Sep 9, 2019
4f92a94
fix createAppImagesObject
Lindsay-Needs-Sleep Sep 9, 2019
cbbe190
Merge Lewazo's changes. Filter out active duplicate routes and dupli…
Lindsay-Needs-Sleep Sep 9, 2019
20e5381
Added tests for session Leave and session Stop. Cleaned up their fun…
Lindsay-Needs-Sleep Sep 10, 2019
3d4792b
Added package.json script to automatically fix the js errors it can.
Lindsay-Needs-Sleep Sep 10, 2019
101a69f
Got the plugin to automatically resume sessions after being the app h…
Lindsay-Needs-Sleep Sep 11, 2019
b31da28
Should technically mark the package version as a "dev" version until …
Lindsay-Needs-Sleep Sep 11, 2019
39dad44
(android) Make the constants match the desktop chrome SDK.
Lindsay-Needs-Sleep Sep 11, 2019
aaac51e
Fixed all kinds of problems with setVolume (media and receiver)
Lindsay-Needs-Sleep Sep 12, 2019
eaf54c1
Got a remote video for testing instead! Wonderful! Thanks @anthonyl…
Lindsay-Needs-Sleep Sep 12, 2019
125f37f
SessionManager.startSession did not work reliably on android 4.4.2, s…
Lindsay-Needs-Sleep Sep 15, 2019
881106e
Merge remote-tracking branch 'remotes/jellyfin/master' into 1.0.0
Lindsay-Needs-Sleep Sep 15, 2019
1b066d1
Fixed up mediaLoaded. It should be called whenever a new media is lo…
Lindsay-Needs-Sleep Sep 15, 2019
188ffe0
_mediaUpdated event is already fired by Media.prototype._update, so w…
Lindsay-Needs-Sleep Sep 15, 2019
314b33e
Only ChromecastSession needs to hold a reference to session.
Lindsay-Needs-Sleep Sep 15, 2019
605e2a3
(android) (Refactor) Move JSONObject creator functions to utilities.
Lindsay-Needs-Sleep Sep 15, 2019
f5fdfb7
(android) (Refactor) Decouple the 3 way dependency between Chromecast…
Lindsay-Needs-Sleep Sep 15, 2019
fd9faaa
Merge remote-tracking branch 'remotes/jellyfin/master' into 1.0.0
Lindsay-Needs-Sleep Sep 15, 2019
2c4cdad
Improve selectRoute with some error handling.
Lindsay-Needs-Sleep Sep 15, 2019
d99c93a
Improve loadMediaVideo test
Lindsay-Needs-Sleep Sep 15, 2019
1769e72
Add test to check for video finished state
Lindsay-Needs-Sleep Sep 19, 2019
0fe247b
(android) Remove sendJavascript and replace with an event callback th…
Lindsay-Needs-Sleep Sep 22, 2019
5dc73a6
Update package script to have the standard "npm test"
Lindsay-Needs-Sleep Sep 25, 2019
ad75977
Move the Api isAvailable check to a central location
Lindsay-Needs-Sleep Sep 25, 2019
dce633f
(android) Add some notes and error detection for Android 4.4 mysterio…
Lindsay-Needs-Sleep Sep 25, 2019
fcb1daf
Add check to make sure initialize has been successfully called before…
Lindsay-Needs-Sleep Sep 25, 2019
ff3d595
Should make sure _session exists before trying to use it since this e…
Lindsay-Needs-Sleep Sep 26, 2019
444286b
Improvements for selectRoute and requestSession.
Lindsay-Needs-Sleep Sep 26, 2019
227aa83
Improve error handling to allow native responses to send a JSONObject…
Lindsay-Needs-Sleep Sep 26, 2019
6afa22d
Protect against user passing null as _receiverListener or _sessionLis…
Lindsay-Needs-Sleep Sep 28, 2019
390d456
Improved startRouteScan/stopRouteScan to handle multiple calls better.
Lindsay-Needs-Sleep Sep 28, 2019
a7cc809
(android) Remove e.printStackTrace when building JSONObjects.
Lindsay-Needs-Sleep Sep 28, 2019
a04f0e4
Kill any route scan that may be going on when setup is called.
Lindsay-Needs-Sleep Sep 29, 2019
6408db0
Only update session.addMediaListnener (MEDIA_LOADED event) when an ex…
Lindsay-Needs-Sleep Sep 29, 2019
9f3b235
Issue #50 Issue #36 Converted the existing auto tests to mocha and mi…
Lindsay-Needs-Sleep Oct 1, 2019
d25ed20
Added ability to run tests on chrome to confirm that functionality ma…
Lindsay-Needs-Sleep Oct 1, 2019
89ca848
Fix chai.js, fix typos in readme, fix css import, rename runner since…
Lindsay-Needs-Sleep Oct 4, 2019
f1721a9
Fixed up Metadata, added some tests.
Lindsay-Needs-Sleep Oct 4, 2019
5f9e343
Issue #23 Fix up the metadata to handle more than strings (Chromecast…
Lindsay-Needs-Sleep Oct 6, 2019
a05b187
Include Mocha fix PR #4051 because I just tried it out and it's nice …
Lindsay-Needs-Sleep Oct 8, 2019
6dd8907
Fix tests html, and improve utils output of callOrder functions a bit
Lindsay-Needs-Sleep Oct 13, 2019
de16c09
Fix crash because of NullPointerException. https://github.com/milopro…
Lindsay-Needs-Sleep Oct 16, 2019
574b327
Added base queue functions. Towards issue #36
Lindsay-Needs-Sleep Oct 17, 2019
c5cee81
Improve tests styling a bit
Lindsay-Needs-Sleep Oct 17, 2019
60e3c01
In tests_auto.js improve error output and move setup items to setup.
Lindsay-Needs-Sleep Oct 19, 2019
0dbe15c
Added beginning of manual tests (requestSession)
Lindsay-Needs-Sleep Oct 19, 2019
d42462a
Added the restart app / rejoin session manual test
Lindsay-Needs-Sleep Oct 20, 2019
1126487
Added more manual Tests. Added all the major ones where multiple dev…
Lindsay-Needs-Sleep Oct 20, 2019
b357e6b
finished auto tests
CodeHole7 Nov 12, 2019
4c40625
Added a bit more specific instructions to manual tests
Lindsay-Needs-Sleep Nov 12, 2019
3021c84
Auto tests are fixed
CodeHole7 Nov 13, 2019
47b7f66
manual and auto tests completed
CodeHole7 Nov 15, 2019
c2af2ab
Auto and manual tests completed
CodeHole7 Nov 16, 2019
84fb9f5
auto and manual tests are finished
CodeHole7 Nov 16, 2019
9d4d070
Fix bug. Js failure if trying to unset media on non-existent session.
Lindsay-Needs-Sleep Nov 17, 2019
ebfa96d
Add tests that specifically test that initialize will return any acti…
Lindsay-Needs-Sleep Nov 17, 2019
fa39558
Improve manual instructions a bit and fix forgotten closing quotes in…
Lindsay-Needs-Sleep Nov 17, 2019
a818387
Apparently ios deletes cookies during app restart. So switch to local…
Lindsay-Needs-Sleep Nov 17, 2019
679c446
Move the sessionRejoin event to after the initialize success callback…
Lindsay-Needs-Sleep Nov 17, 2019
0bce6c4
Give slightly longer timeout to accommodate slower devices
Lindsay-Needs-Sleep Nov 17, 2019
470e308
Fix session being returned twice on app restart / session rejoin
Lindsay-Needs-Sleep Nov 17, 2019
cb30f87
Fix for iOS 9. iOS 9 does not support [NSTimer scheduledTimerWithTim…
Lindsay-Needs-Sleep Nov 17, 2019
52ec111
Style changes. Xcode is determined to do this.
Lindsay-Needs-Sleep Nov 17, 2019
0be770c
(ios) ensure that the scan is running while attempting to selectRoute.
Lindsay-Needs-Sleep Nov 17, 2019
8ac80dd
Make manual test buttons bigger for ios.
Lindsay-Needs-Sleep Nov 18, 2019
041c1ea
Forgot to apply some button ids
Lindsay-Needs-Sleep Nov 18, 2019
5153119
Updated readme with api description and example js
Lindsay-Needs-Sleep Nov 18, 2019
56c371d
Merge remote-tracking branch 'remotes/jellyfin/master' (Jellyfin upda…
Lindsay-Needs-Sleep Nov 18, 2019
1a04867
version update 1.0.0
Lindsay-Needs-Sleep Nov 18, 2019
6ea9b29
(ios) Added instructions for meeting ios app distribution requirements
Lindsay-Needs-Sleep Nov 19, 2019
7a0848e
Update google cast library to 4.4.6 which supports iOS 9.0+
Lindsay-Needs-Sleep Nov 23, 2019
3d8cb98
(ios) remove unused emitAllRoutes
Lindsay-Needs-Sleep Nov 25, 2019
b242f8f
[non-change] typo and empty lines change
Lindsay-Needs-Sleep Nov 25, 2019
7ddc056
(ios) we don't use sendJavascript anymore
Lindsay-Needs-Sleep Nov 25, 2019
d5d1778
(ios) Move device list building to utilities. Simplify receiverListen…
Lindsay-Needs-Sleep Nov 25, 2019
9cf5d02
(ios) media must be an array when returned in session
Lindsay-Needs-Sleep Nov 25, 2019
cf61f6b
(ios) decrease cast utilties code duplication
Lindsay-Needs-Sleep Nov 25, 2019
4a3c03d
(ios) fix startTime and preloadTime, check for invalidTimeInterval an…
Lindsay-Needs-Sleep Nov 25, 2019
1d67ed4
(ios) Let ChromecastSession handle all the rejoining logic (also chan…
Lindsay-Needs-Sleep Nov 25, 2019
dcc954d
(ios) Modify the way scans keep track of whether or not to stop a sca…
Lindsay-Needs-Sleep Nov 25, 2019
a271c9c
(ios) [no change] Remove sendScan (forgot to remove on commit "(ios) …
Lindsay-Needs-Sleep Nov 25, 2019
17fc854
(ios) [no change] Remove createSessionObject (the one with no "status…
Lindsay-Needs-Sleep Nov 25, 2019
d29c21b
(ios) create one endSession function
Lindsay-Needs-Sleep Nov 25, 2019
37c3f88
(ios) try to join selected route for 5 seconds
Lindsay-Needs-Sleep Dec 1, 2019
8feaf99
(ios) WIP remove isAlive param, it is never used in these contexts, j…
Lindsay-Needs-Sleep Dec 1, 2019
b714545
(ios) Add CDVPlugin event onReset so that we can stop scans from runn…
Lindsay-Needs-Sleep Dec 1, 2019
1cceb85
(ios) WIP fix requestSession bug where it was not getting the devices…
Lindsay-Needs-Sleep Dec 1, 2019
64035e6
(test) Ensure that chromecast is initialized in before of describe te…
Lindsay-Needs-Sleep Dec 1, 2019
0ca8d4f
(ios) WIP Calculate the session's status except for the case when we …
Lindsay-Needs-Sleep Dec 1, 2019
e7a38b0
(ios) WIP Added endSessionWithCallback to reduce code duplication by …
Lindsay-Needs-Sleep Dec 2, 2019
f18e5cc
(test) WIP session.stop should happen in a specific order
Lindsay-Needs-Sleep Dec 2, 2019
2e35bab
(test) WIP Remove some unintended copy pasta
Lindsay-Needs-Sleep Dec 2, 2019
95496d6
(test) (ios) WIP ensure there is no idelReason when media is active
Lindsay-Needs-Sleep Dec 2, 2019
5e7e7f3
(ios) WIP remove isRequesting and create slighlty unified requestDele…
Lindsay-Needs-Sleep Dec 2, 2019
2d53b58
(ios) WIP fix/unify setMediaVolumeWithCommand so that we have just on…
Lindsay-Needs-Sleep Dec 2, 2019
2c5a566
(ios) WIP Add createLoadMediaRequestDelegate to unify the load reques…
Lindsay-Needs-Sleep Dec 2, 2019
cdc69fe
(ios) WIP Use lastMedia to keep track of when the next item in a queu…
Lindsay-Needs-Sleep Dec 2, 2019
fe3d54c
(ios) WIP Switch to using isQueueJumping to determine the reason for …
Lindsay-Needs-Sleep Dec 2, 2019
34b4cfa
(ios) WIP Allow storing multiple callbacks for when the session ends.…
Lindsay-Needs-Sleep Dec 2, 2019
bd08dcd
(ios) WIP Forgot to commit these changes with their relevant commit. …
Lindsay-Needs-Sleep Dec 2, 2019
68de02e
(ios) WIP fix crash when textTrackStyle.backgroundColor does not exist
Lindsay-Needs-Sleep Dec 2, 2019
aec5395
(ios) WIP Fix contentID output. For queues, only contentURL is avail…
Lindsay-Needs-Sleep Dec 2, 2019
a89f8fa
(ios) WIP bug fix, selectRoute should only return the "Leave/Stop cur…
Lindsay-Needs-Sleep Dec 2, 2019
4fb7b21
(ios) WIP sometimes initialize -> tryRejoin can happen before didEndC…
Lindsay-Needs-Sleep Dec 2, 2019
8ec8c98
(ios) WIP For some reason didResumeCastSession is called randomly eve…
Lindsay-Needs-Sleep Dec 2, 2019
46b795d
(ios) WIP detect join session fail and return an error
Lindsay-Needs-Sleep Dec 2, 2019
620b3ab
(test) WIP fix test "ueue should start the next item automatically wh…
Lindsay-Needs-Sleep Dec 2, 2019
ddfcf3c
(test) WIP fix copypasta
Lindsay-Needs-Sleep Dec 2, 2019
14e1fea
(test) WIP allow requestSession's stop casting option to trigger the …
Lindsay-Needs-Sleep Dec 2, 2019
1341f9d
(test) WIP auto tests should have a before which ensures that initial…
Lindsay-Needs-Sleep Dec 2, 2019
c30f6fb
(test) WIP wrap media functions in a describe to improve ".only" use …
Lindsay-Needs-Sleep Dec 2, 2019
123e229
[no change] formatting. Change indent for tests required from last 2 …
Lindsay-Needs-Sleep Dec 2, 2019
068baa2
[no change] satisfy eslint and miniscule performance boost
Lindsay-Needs-Sleep Dec 2, 2019
4e26335
(ios) Have the plugin start onload. This is supposed to be required…
Lindsay-Needs-Sleep Dec 2, 2019
3eedaad
(ios) Fix issue https://github.com/miloproductionsinc/cordova-plugin-…
Lindsay-Needs-Sleep Dec 2, 2019
f57226a
(ios) [no change] remove unused function
Lindsay-Needs-Sleep Dec 2, 2019
50fcb79
(test) format the test homepage to look a bit nicer
Lindsay-Needs-Sleep Dec 2, 2019
ea54bfa
(test) Do not require the receiver updates for the before initialize …
Lindsay-Needs-Sleep Dec 2, 2019
95f6ba0
(ios) Fix communication problem with Android. Android still requires…
Lindsay-Needs-Sleep Dec 3, 2019
8e263f6
(test) allow media after resume to be buffering or playing
Lindsay-Needs-Sleep Dec 3, 2019
fcda993
(android) Improve/simplify queue item handling
Lindsay-Needs-Sleep Dec 3, 2019
3ea9d0c
(android) Add a try catch on initialization so that devices incapable…
Lindsay-Needs-Sleep Dec 9, 2019
5694a72
(test) Change audioUrl because old one is gone. Fix readme typo.
Lindsay-Needs-Sleep Jan 14, 2020
14d607e
Improve queueReloadCallback handling. Unset it when an error occurs.…
Lindsay-Needs-Sleep Jan 16, 2020
a571043
(android) remove annoying e.printStackTrace's for invalid (but option…
Lindsay-Needs-Sleep Jan 16, 2020
c71302b
Added 2 tests:
Lindsay-Needs-Sleep Jan 16, 2020
6ec70de
(ios) build returned objects line-by-line instead of all at once to e…
Lindsay-Needs-Sleep Jan 18, 2020
c4a9cbb
Handle invalid application receiver ids better
Lindsay-Needs-Sleep Jan 19, 2020
d4f33a2
(test) Improve duration checking
Lindsay-Needs-Sleep Jan 20, 2020
dd37850
(android) queues should only load 2-3 items into media.items. If cur…
Lindsay-Needs-Sleep Jan 19, 2020
5456d28
(ios) fix orderId on queue itmes
Lindsay-Needs-Sleep Jan 21, 2020
81b7795
Improve error output from waitForAllCalls
Lindsay-Needs-Sleep Jan 21, 2020
35f622a
[no change] just a little cleanup, return nothing instead of return f…
Lindsay-Needs-Sleep Jan 21, 2020
e343fee
(ios) Fix https://github.com/miloproductionsinc/cordova-plugin-chrome…
Lindsay-Needs-Sleep Jan 21, 2020
d7371ff
Add a little protection from js errors if a media update event is sen…
Lindsay-Needs-Sleep Jan 21, 2020
5fde385
(ios) move retry utility function to CastUtilities
Lindsay-Needs-Sleep Jan 24, 2020
ef04641
(test) should have a timeout for this test
Lindsay-Needs-Sleep Jan 24, 2020
650a6ee
(ios) Fixes https://github.com/miloproductionsinc/cordova-plugin-chro…
Lindsay-Needs-Sleep Jan 24, 2020
fd4d669
(ios) remove NSLog's
Lindsay-Needs-Sleep Jan 24, 2020
d47546a
(ios) (wip) remame objc files to have a namespace
Lindsay-Needs-Sleep Jan 25, 2020
35cd482
(ios) Fix imports and usage after file + class rename
Lindsay-Needs-Sleep Jan 25, 2020
2cb3b33
(ios) improve error handling for loadMediaCallback
Lindsay-Needs-Sleep Jan 25, 2020
a668f07
Fix https://github.com/miloproductionsinc/cordova-plugin-chromecast/i…
Lindsay-Needs-Sleep Jan 25, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root: true
extends: semistandard
rules:
indent:
- error
- 4
camelcase: off
padded-blocks: off
operator-linebreak: off
no-throw-literal: off
33 changes: 33 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!--
Please make sure the checklist boxes are all checked before submitting the PR.

Thanks!
-->

### Platforms affected



### Motivation and Context
<!-- Why is this change required? What problem does it solve? -->
<!-- If it fixes an open issue, please link to the issue here. -->



### Description



### Testing
<!-- Please describe in detail how you tested your changes. -->



### Checklist
<!-- Place and x inside the [ ] to indicate completion -->

- [ ] I've updated the documentation as necessary
- [ ] If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct [keyword to close issues using keywords](https://help.github.com/articles/closing-issues-using-keywords/))
- [ ] I've run `npm test` and no errors were found (run `npm style` to auto-fix errors it can)
- [ ] I've run the tests (See Readme)
- [ ] I added automated test coverage as appropriate for this change (See Readme Contributing section)
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,5 @@ Temporary Items

# Created by .ignore support plugin (hsz.mobi)
node_modules

package-lock.json
199 changes: 187 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,200 @@
<h1 align="center">cordova-plugin-chromecast</h1>
<h3 align="center">Chromecast in Cordova</h3>
<h3 align="center">Control Chromecast from your Cordova app</h3>

## Installation
Add the plugin with the command below in your cordova project directory.
# Installation

```
cordova plugin add https://github.com/jellyfin/cordova-plugin-chromecast.git
```

If you have NodeJS installed, the dependencies should be automatically copied. Otrherwise, you will need to import the following projects as Library Projects in order for this plugin to work.
### Additional iOS Installation Instructions
To **distribute** an iOS app with this plugin you must add usage descriptions to your project's `config.xml`.
These strings will be used when asking the user for permission to use the microphone and bluetooth.
```xml
<!-- ios 6-13 (deprecated) -->
<platform name="ios">
<config-file parent="NSBluetoothPeripheralUsageDescription" target="*-Info.plist">
<string>Bluetooth is required to scan for nearby Chromecast devices with guest mode enabled.</string>
</config-file>
<!-- ios 13+ -->
<config-file parent="NSBluetoothAlwaysUsageDescription" target="*-Info.plist">
<string>Bluetooth is required to scan for nearby Chromecast devices with guest mode enabled.</string>
</config-file>
<config-file parent="NSMicrophoneUsageDescription" target="*-Info.plist">
<string>The microphone is required to pair with nearby Chromecast devices with guest mode enabled.</string>
</config-file>
</platform>
```

# Supports

**Android** 4.4+ (7.x highest confirmed) (may support lower, untested)
**iOS** 9.0+ (13.2.1 highest confirmed)

## Quirks
* Android 4.4 (maybe 5.x and 6.x) are not able automatically rejoin/resume a chromecast session after an app restart.

# Usage

This project attempts to implement the [official Google Cast API for Chrome](https://developers.google.com/cast/docs/reference/chrome#chrome.cast) within the Cordova webview.
This means that you should be able to write almost identical code in cordova as you would if you were developing for desktop Chrome.

We have not implemented every function in the [API](https://developers.google.com/cast/docs/reference/chrome#chrome.cast) but most of the core functions are there. If you find a function is missing we welcome [pull requests](#contributing)! Alternatively, you can file an [issue](https://github.com/jellyfin/cordova-plugin-chromecast/issues), please include a code sample of the expected functionality if possible!

The most significant usage difference between the [cast API](https://developers.google.com/cast/docs/reference/chrome#chrome.cast) and this plugin is the initialization.

In **Chrome desktop** you would do:
```js
window['__onGCastApiAvailable'] = function(isAvailable, err) {
if (isAvailable) {
// start using the api!
}
};
```

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


### Example
Here is a simple [example](doc/example.js) that loads a video, pauses it, and ends the session.

## API
Here are the support [Chromecast API]((https://developers.google.com/cast/docs/reference/chrome#chrome.cast)) methods. Any object types required by any of these methods are also supported. (eg. chrome.cast.ApiConfig)

[chrome.cast.initialize](https://developers.google.com/cast/docs/reference/chrome/chrome.cast#.initialize)
[chrome.cast.requestSession](https://developers.google.com/cast/docs/reference/chrome/chrome.cast#.requestSession)
[chrome.cast.setCustomReceivers](https://developers.google.com/cast/docs/reference/chrome/chrome.cast#.setCustomReceivers)
[chrome.cast.Session.setReceiverVolumeLevel](https://developers.google.com/cast/docs/reference/chrome/chrome.cast.Session#setReceiverVolumeLevel)
[chrome.cast.Session.setReceiverMuted](https://developers.google.com/cast/docs/reference/chrome/chrome.cast.Session#setReceiverMuted)
[chrome.cast.Session.stop](https://developers.google.com/cast/docs/reference/chrome/chrome.cast.Session#stop)
[chrome.cast.Session.leave](https://developers.google.com/cast/docs/reference/chrome/chrome.cast.Session#leave)
[chrome.cast.Session.sendMessage](https://developers.google.com/cast/docs/reference/chrome/chrome.cast.Session#sendMessage)
[chrome.cast.Session.loadMedia](https://developers.google.com/cast/docs/reference/chrome/chrome.cast.Session#loadMedia)
[chrome.cast.Session.queueLoad](https://developers.google.com/cast/docs/reference/chrome/chrome.cast.Session#queueLoad)
[chrome.cast.Session.addUpdateListener](https://developers.google.com/cast/docs/reference/chrome/chrome.cast.Session#addUpdateListener)
[chrome.cast.Session.removeUpdateListener](https://developers.google.com/cast/docs/reference/chrome/chrome.cast.Session#removeUpdateListener)
[chrome.cast.Session.addMessageListener](https://developers.google.com/cast/docs/reference/chrome/chrome.cast.Session#addMessageListener)
[chrome.cast.Session.removeMessageListener](https://developers.google.com/cast/docs/reference/chrome/chrome.cast.Session#removeMessageListener)
[chrome.cast.Session.addMediaListener](https://developers.google.com/cast/docs/reference/chrome/chrome.cast.Session#addMediaListener)
[chrome.cast.Session.removeMediaListener](https://developers.google.com/cast/docs/reference/chrome/chrome.cast.Session#removeMediaListener)
[chrome.cast.media.Media.play](https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.Media.html#play)
[chrome.cast.media.Media.pause](https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.Media.html#pause)
[chrome.cast.media.Media.seek](https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.Media.html#seek)
[chrome.cast.media.Media.stop](https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.Media.html#stop)
[chrome.cast.media.Media.setVolume](https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.Media.html#setVolume)
[chrome.cast.media.Media.supportsCommand](https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.Media.html#supportsCommand)
[chrome.cast.media.Media.getEstimatedTime](https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.Media.html#getEstimatedTime)
[chrome.cast.media.Media.editTracksInfo](https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.Media.html#editTracksInfo)
[chrome.cast.media.Media.queueJumpToItem](https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.Media.html#queueJumpToItem)
[chrome.cast.media.Media.addUpdateListener](https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.Media.html#addUpdateListener)
[chrome.cast.media.Media.removeUpdateListener](https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.Media.html#removeUpdateListener)


### Specific to this plugin
We have added some additional methods unique to this plugin.
They can all be found in the `chrome.cast.cordova` object.

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)
}, function (err) {
// Will return with err.code === chrome.cast.ErrorCode.CANCEL when the scan has been ended
});

// When the user selects a route
// stop the scan to save battery power
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
}, function (err) {
// Failed to connect to the route
});

```

**Route** object
```text
id {string} - Route id
name {string} - User friendly route name
isCastGroup {boolean} - Is the route a cast group?
isNearbyDevice {boolean} - Is it a device only accessible via guest mode?
(aka. probably not on the same network, but is nearby and allows guests)
```


# Plugin Development

## Setup

Follow these direction to set up for plugin development:

* You will need an existing cordova project or [create a new cordova project](https://cordova.apache.org/#getstarted).
* Add the chromecast and chromecast tests plugins:
* `cordova plugin add --link <path to plugin>`
* `cordova plugin add --link <path to plugin>/tests`
* This --link** option may require **admin permission**

#### **About the `--link` flag
The `--link` flag allows you to modify the native code (java/swift/obj-c) directly in the relative platform folder if desired.
* This means you can work directly from Android Studio/Xcode!
* Note: Be careful about adding and deleting files. These changes will be exclusive to the platform folder and will not be transferred back to your plugin folder.
* Note: The link only works for native files. Other files such as js/css/html/etc must **not** be modified in the platform folder, these changes will be lost.
* To update the js/css/html/etc files you must run:
* `cordova plugin remove <plugin-name>`
* With **admin permission**: `cordova plugin add --link <relative path to the plugin's root dir>`

## Testing

### Code Format

Run `npm test` to ensure your code fits the styling. It will also find some errors.

* If errors are found, you can try running `npm run style`, this will attempt to automatically fix the errors.

### Tests Mobile
Requirements:
* A chromecast device

How to run the tests:
* Follow [setup](#setup)
* Change `config.xml`'s content tag to `<content src="plugins/cordova-plugin-chromecast-tests/www/html/tests.html" />`

Auto tests:
* Run the app, select auto tests, let it do its thing

- `adt-bundle\sdk\extras\google\google_play_services\libproject\google-play-services_lib`
- `adt-bundle\sdk\extras\android\support\v7\appcompat`
- `adt-bundle\sdk\extras\android\support\v7\mediarouter`
Manual tests:
* This tests tricky features of chromecast such as:
* Resume casting session after page reload / app restart
* Interaction between 2 devices connected to the same session
* You will need to be able to run the tests from 2 different devices (preferred) or between a device and chrome desktop browser
* To use the chrome desktop browser see [Tests Chrome](#tests-chrome)

## Usage
[Why we chose a non-standard test framework](https://github.com/jellyfin/cordova-plugin-chromecast/issues/50)

This project attempts to implement the official Google Cast SDK for Chrome within Cordova. We've made a lot of progress in making this possible, so check out the [offical documentation](https://developers.google.com/cast/docs/chrome_sender) for examples.
### Tests Chrome

When you call `chrome.cast.requestSession()` a popup will be displayed to select a Chromecast. If you would prefer to make your own interface you can call `chrome.cast.getRouteListElement()` which will return a `<ul>` tag that contains the Chromecasts in a list. All you have to do is style that bad boy and you're off to the races!
The auto tests also run in desktop chrome.
They use the google provided cast_sender.js.
These are particularly useful for ensuring we are following the [official Google Cast API for Chrome](https://developers.google.com/cast/docs/reference/chrome#chrome.cast) correctly.
To run the tests:
* run: `npm run host-chrome-tests [port default=8432]`
* Navigate to: `http://localhost:8432/chrome/tests_chrome.html`

## Status
## Contributing

The project is now pretty much feature complete - the only things that will possibly break are missing parameters. We haven't done any checking for optional paramaters. When using the plugin make sure your constructors and function calls have every parameter you can find in the method declarations.
* Write a test for your contribution if applicable (for a bug fix, new feature, etc)
* You should test on [Chrome](#tests-chrome) first to ensure you are following [Google Cast API](https://developers.google.com/cast/docs/reference/chrome#chrome.cast) behavior correctly
* If the test does not pass on [Chrome](#tests-chrome) we should not be implementing it either (unless it is a `chrome.cast.cordova` function)
* Make sure all tests pass ([Code Format](#code-format), [Tests Mobile](#tests-mobile), and [Tests Chrome](#tests-chrome))
* Update documentation as necessary
Loading