Giter Site home page Giter Site logo

miloproductionsinc / cordova-plugin-chromecast Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jellyfin-archive/cordova-plugin-chromecast

13.0 13.0 16.0 1.05 MB

Control Chromecast from Cordova

License: Other

JavaScript 53.30% Java 26.22% Objective-C 18.57% HTML 1.79% CSS 0.13%

cordova-plugin-chromecast's People

Contributors

anthonylavado avatar codehole7 avatar dkanada avatar emilsas avatar enricodente avatar froghut avatar grahamkennery avatar joshuaboniface avatar judeosborn avatar jumbay avatar justaman avatar kibotu avatar lewazo avatar lindsay-needs-sleep avatar matbee-eth avatar mmocny avatar pgcan avatar rejhgadellaa avatar sel-en-ium avatar th3hamm0r avatar vaporexpress avatar vitorsemeano avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

cordova-plugin-chromecast's Issues

Cannot sendMessage() to cast URL

Hello and thanks for this amazing plugin.

I have set it up and got the example with the video and pause/stop working in few minutes.

Unfortunately, that is not the use I would like to achieve: I would need to open a remote URL on the screen. I have found this project that uses Chromecast APIs and works like a charm on their web-example using Chrome browser:
Project: https://github.com/DeMille/url-cast-receiver
Example: https://demille.github.io/url-cast-receiver/

Basically, I would like to achieve that using this plugin.
I have tried to adapt their implementation inside my test cordova app, but I always get issues when calling the requestSession method: the error callback gets triggered, and the error I get is: "namespace 'urn:x-cast:com.url.cast' not founded unverified"

I have tried both using the recommended App ID and namespace from the project, and also tried using one generated by me, but always get that error. After that, it looks like I can no longer close the session, not even force closing the app, so the only way to be able to scan again my Chromecast TV is to uninstall the app and re-install again, but I believe this is only a side effect of the main issue.

Thanks for any hint!

Can't connect to 2nd gen Google Chromecast / silent fail with unregistered devices and unpublished Cast app

I got a new/old Chromecasts today. My 3rd gen has always worked; the 2nd gen does not.

  • it does not show up in the default OS route selector
  • this affects both iOS and Android
  • it does show up in chrome.cast.cordova.startRouteScan
  • but when I use its id for chrome.cast.cordova.selectRoute, I get a timeout Error:
    Failed to join route (com.google.android.gms/.cast…7acf00xxxxxxxxxxxx) after 15s and 1 tries.
  • this also happens when I update the Cast Framework #19 (comment)
  • other apps, both big (Netflix/YouTube) and small have no problems finding the Chromecast
  • we've also experienced connection errors with other 3rd party Chromecasts.

// I know that this repo is unmaintained.

(android) [Intermittent] NO_DEVICES_AVAILABLE after restarting app after leaving shared session

Given this situation:

  1. Device 1 and 2 both join the same sesssion
  2. Device 1 does session.leave or session.stop
  3. Restart the app on Device 1, and call chrome.cast.initialize again
  4. (the bug) receiverListener never gets called with availability == true

This is tested in the manual tests on the primary device. The end of tests_manual_primary_1 and
the beginning of tests_manual_primary 2 tests this.

NOTE: The bug lasts longer when doing session.leave. The bug seems to last until one of 2 things happen:

  • The session has been killed AND some time has passed. (since session.leave does not kill the session the bug lasts longer)
  • The app is completely wiped from memory eg. re-install or settings > Apps > > "Force Stop"

This bug is extra strange because if you don't restart the app, it is happy to signal that receivers are available during chrome.cast.initialize.

The source of the bug is here:
ChromecastConnection.java >
initialize() { >
startRouteScan/ScanCallback/onRouteUpdate >
if (getContext().getCastState() != CastState.NO_DEVICES_AVAILABLE) { (line 107)
Never evaluates to true

This is very strange because onRouteUpdate is called with the actual valid route. Meaning there are indeed routes available. Not sure why getContext().getCastState() thinks there isn't.

This also only happens on one device that I have tested.
(Samsung tablet, SM-T350, Galaxy Tab A, Android 7.0)
The other device I test on is fine. (LG Phone, LG-M151, LG K4, Android 6.0.1)

this._getMedia() is undefined

I still got the error mentioned on #8 with the latest version:

Unhandled Promise rejection:  "undefined is not an object (evaluating 'this._getMedia().mediaSessionId = 'invalidated'')"  "; Zone:"  "<root>"  "; Task:"  "Promise.then"  "; Value:" (2)
TypeError: undefined is not an object (evaluating 'this._getMedia().mediaSessionId = 'invalidated'') — chrome.cast.js:893
"http://localhost:8100/plugins/cordova-plugin-chromecast/www/chrome.cast.js:893:21
http://localhost:8100/plugins/cordova-plugin-chromecast/www/chrome.cast.js:731:31
http://localhost:8100/plugins/cordova-plugin-chromecast/www/chrome.cast.js:1476:65
callbackFromNative@http://localhost:8100/cordova.js:295:63
http://localhost:8100/plugins/cordova-plugin-ionic-webview/src/www/ios/ios-wkwebview-exec.js:129:35

(ios) On app restart (with active media), if session is immediately returned, there is no media object

Originally posted by @JumBay in #6 (comment)

It seems working, but not all the time. I got an error sometimes on the first play and I don't receive any events even if the video plays on the chromecast:

Unhandled Promise rejection: – "undefined is not an object (evaluating 'this._getMedia().mediaSessionId = 'invalidated'')" – "; Zone:" – "<root>" – "; Task:" – "Promise.then" – "; Value:" (2)
TypeError: undefined is not an object (evaluating 'this._getMedia().mediaSessionId = 'invalidated'') — chrome.cast.js:893
"http://localhost:8100/plugins/cordova-plugin-chromecast/www/chrome.cast.js:893:21
http://localhost:8100/plugins/cordova-plugin-chromecast/www/chrome.cast.js:731:31
http://localhost:8100/plugins/cordova-plugin-chromecast/www/chrome.cast.js:1476:65
callbackFromNative@http://localhost:8100/cordova.js:295:63
http://localhost:8100/plugins/cordova-plugin-ionic-webview/src/www/ios/ios-wkwebview-exec.js:129:35

If I wrap this with a try catch block I don't have the error anymore obviously, but on the restart, the issue is still present

(ios) can't control media after session is returned after app restart

Originally found by @JumBay here

I did find another similar issue.
Cast something, kill the app, reopen it. The session will be retrieved, the media will be retrieved as well with the right playerState but you cannot interact with the media object anymore, play, pause... methods have no effect.

May be a bug on Android as well.

App crash after initiating audio-casting on iOS: 'Invalid number value (infinite) in JSON write'

This issue kind of duplicates jellyfin-archive#53, but I thought it better fits to your fork, since I've used your latest master. Also I've some additional information:

  • I've used the code of your example, but replaced the mp4-URL with an URL targeting a mp3-stream.
  • The cast app gets started, so the loadMedia-Call seems to work on the remote device, but the app crashes before any of the loadMedia-callbacks are called.

Stopped working recently?

We use this in our app and it stopped working a few weeks ago. We made a simple app with just this, and still doesn't work.

Gets to the point where you can select a device and cast, but then just a blue Chromecast icon appears on the device.

Anyone seeing something similar?

Select route on behalf of user without requestSession()

Hi! Thank you so much for this plugin! It's been working great so far. More of a question than an issue...

I'm creating a mobile app where I want to show the routes on my own styled UI, and not through the native requestSession popup. Can I obtain a session without the user selecting a route through this requestSession popup.

My app is not casting immediately, but is creating a scheduled task to cast media at certain times of the day. The UI is there to select the route (which I can do without the popup now), and then show a "test" button next to each route for the user to hit it with a quick chirp audio. However sending a test audio requires an active session which seems to only be acquired through the requestSession flow.

Would love any insight on this, and if this is possible in the current set up of this plugin.

"API Not Initialized" error in --release build only

Platform: Android
Cordova: 10.0.0

While compiling --debug version, everything works fine.
Only when compiled as --release I get this error at app startup, when initializing Chromecast plugin, of course anything related to Chromacast is not working after the error.

Anyone else experienced this issue?

{
  "code":"unknown",
  "description":"api_not_initialized null",
  "details":{}
}

Discussion - How to load subtitles

Hi,

Do you know how to load subtitles?

I've tried this:

        var englishSubtitle = new chrome.cast.media.Track(1, chrome.cast.media.TrackType.TEXT);

        englishSubtitle.trackContentId = 'https://thepaciellogroup.github.io/AT-browser-tests/video/subtitles-en.vtt';
        englishSubtitle.trackContentType = 'text/vtt';
        englishSubtitle.subtype = chrome.cast.media.TextTrackType.SUBTITLES;
        englishSubtitle.name = 'English Subtitles';
        englishSubtitle.language = 'en-US';
        englishSubtitle.customData = null;


        var videoUrl = 'https://ia801302.us.archive.org/1/items/TheWater_201510/TheWater.mp4';
        var mediaInfo = new chrome.cast.media.MediaInfo(videoUrl, 'video/mp4');



        mediaInfo.metadata = {
          title: 'My Title',
          images: [new chrome.cast.Image('https://image.tmdb.org/t/p/w300_and_h450_bestv2/udDclJoHjfjb8Ekgsd4FDteOkCU.jpg')],
          tracks:  [englishSubtitle]
        };
        

But it kills the app (removing the tracks doesn't kill the app).

I've also tried the mentioned method here with no luck: https://gist.github.com/guerrerocarlos/3aca64069853d8d24a83b481246f23ca

Thanks

Cast audio

Is there any example on how to integrate it with an audio player. I use the cordova media plugin on my app and I need to be able to cast my audio. I install the plugin but I'm a little lost on how to use it. Any help will be appreciate.

instant crash with Android 13

I could fix/work around this issue by updating the Cast Framework, here's my fork:

bikubi@d118b5b

...but work in progress, need to figure out the compile error.
Also, more testing.

// I know that this repo is unmaintained

sessionListener doesn't contain current media

Hi,

First of all thanks for this great work.

I'm testing your example on an ios simulator. It works, but I've noticed when the sessionListener is called on a restart, for example, the media property is always an empty array even if something is playing.

Is there any way to retrieve the current media?

Thx again

is it support subtitles ?

hi, thank you @Lindsay-Needs-Sleep for handling this plugin
I'm just coming to ask if this plugin support subtitle??, trying a lot of tricks to make it work, but still nothing, the subtitle didn't show
my console log for [this.castMedia] :

"tracks":[
{
"trackId"=1,
"type":"VIDEO",
"trackContentType":null,
"trackContentId":"null",
"subtype":'null',
"name":'null',
"language":'null',
"customData":'null'
}
]

code using for

var videoUrl = 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-576p.mp4';
var thesub = 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.en.vtt';


const englishSubtitle = new chrome.cast.media.Track(1,chrome.cast.media.TrackType.TEXT);
   englishSubtitle.trackContentId =thesub ;
   englishSubtitle.trackContentType = 'text/vtt';
   englishSubtitle.subtype = chrome.cast.media.TextTrackType.SUBTITLES;
   englishSubtitle.name = 'English';
   englishSubtitle.language = 'en-US';
   englishSubtitle.customData = null;
   var tracks = [englishSubtitle];

        var mediaInfo = new chrome.cast.media.MediaInfo(videoUrl);

         /**/ mediaInfo.tracks = tracks;
        mediaInfo.activeTrackIds = [1];
        
      
        this.isCasting = true;
        this.castSession.loadMedia(new chrome.cast.media.LoadRequest(mediaInfo), (media:any)=> {
            // You should see the video playing now!
            // Got media!
            
             this.castMedia = media;
            alert(JSON.stringify(this.castMedia, null, 2));
         
        }, function (err) {
            // Failed (check that the video works in your browser)
           // alert("Failed : check that the video works in your browser")
            alert(JSON.stringify(err, null, 2));
            this.isCasting = false;
           
        });
        
      

'@objc' method name provides one argument name, but method has 0 parameters

Build failed with this error.

'@objc' method name provides one argument name, but method has 0 parameters in Chromecast.swift

@objc(checkReceiverAvailable:)

@objc(checkReceiverAvailable:) 
func checkReceiverAvailable() {
   let sessionManager = GCKCastContext.sharedInstance().sessionManager

   if self.devicesAvailable.count > 0 || (sessionManager.currentSession != nil) {
       self.sendJavascript(jsCommand: "chrome.cast._.receiverAvailable()")
   } else {
       self.sendJavascript(jsCommand: "chrome.cast._.receiverUnavailable()")
   }

 }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.