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

Listen for the X icon action from the cast notification #73

Open
julianCast opened this issue Oct 17, 2020 · 9 comments
Open

Listen for the X icon action from the cast notification #73

julianCast opened this issue Oct 17, 2020 · 9 comments

Comments

@julianCast
Copy link

julianCast commented Oct 17, 2020

Hi again! I'm almost done!
Here is the thing...I'm able to successfully listen to the event from the STOP CASTING button using:

this._session.addUpdateListener(function listenerSession() {
   if (this._session.status === window.chrome.cast.SessionStatus.STOPPED) {  /* here *\ }

photo5789456323069457380

But I'm not able when I touch the X in the cast notification. As far as I understand that stop the session too.

photo5789456323069457381

Thanks !!

@Lindsay-Needs-Sleep
Copy link
Collaborator

Yep, I agree that it should also trigger that event with SessionStatus.STOPPED

This was not something I tested.

The second picture, is that from an Android home screen? Or the locked screen?
(All of my test devices have their lock screens disabled so I never encountered this UI. Do you have to do anything special to enable it?)

If it is on the locked screen, it might be a bit difficult to get the event triggered (since the app might not be running). Not sure.

@julianCast
Copy link
Author

julianCast commented Oct 18, 2020

That wasn't the locks creen, just the notification when I slide down the screen (having the app open behind)

The pause icon does trigger its event.

@Lindsay-Needs-Sleep
Copy link
Collaborator

Ooh okay!

Well it should be fairly easy to get that work properly then I think/hope.

(I’m guessing the close event is being ignored on the native side for some reason. Or maybe the notification close/stop casting event needs a different listener.)

I won’t have time for quite awhile (3 weeks+) to look at this.

If you are interested in fixing this, I can point you at code sections that I think would be relevant.

@julianCast
Copy link
Author

Oh ok! Yes, I could take a look in the meantime, can provide me some hints? Thanks!

@Lindsay-Needs-Sleep
Copy link
Collaborator

Yep!

I think your best bet is about here:
https://github.com/jellyfin/cordova-plugin-chromecast/blob/master/src/android/ChromecastSession.java#L129

In particular:

                    @Override
                    public void onApplicationDisconnected(int i) {
                        clientListener.onSessionEnd(
                                ChromecastUtilities.createSessionObject(session, "stopped"));
                    }

My guess is that this event isn't being triggered.
Either:

  • there is another event that needs to be listened to in session.addCastListener(new Cast.Listener() {
    • Check documentation for Cast.listener
  • Or session.addCastListener(new Cast.Listener() { is not getting called in time. (I doubt it is this.)

clientListener.onSessionEnd(ChromecastUtilities.createSessionObject(session, "stopped")); is the part that actually results in calling/triggering the javascript event. So you just need to figure out where this additionally needs to be called.

@Lindsay-Needs-Sleep
Copy link
Collaborator

I am working on some chromecast stuff now, @julianCast if you have had any luck with figuring this out, please let me know! (I will hopefully be able to test and add it)

@julianCast
Copy link
Author

I am right now looking into it, but so far is not something obvious, the session.addCastListener is listening all the events availables, except for onActiveInputStateChanged, but that is not related to stop session.

@julianCast
Copy link
Author

Debuggin here: https://github.com/jellyfin/cordova-plugin-chromecast/blob/master/www/chrome.cast.js#L1439

When I quit the session within the app I get as eventname:
RECEIVER_LISTENER then SESSION_UPDATE (which is the one that trigger the event stopped)

When I quit the session using the notification I do get something, but only:
RECEIVER LISTENER

@Lindsay-Needs-Sleep
Copy link
Collaborator

(I finally got around to try it myself, can confirm that it doesn't work right)

Interesting, so it looks like it is half working. :/
Thanks for checking session.addCastListener! too bad that wasn't the answer. :/

If you find anything else please let me know! (I am on a very tight time schedule so I'm not sure if I will be able to get to it on my own)

Lindsay-Needs-Sleep added a commit to miloproductionsinc/cordova-plugin-chromecast that referenced this issue Oct 31, 2020
…ing button:

Add tests for stop casting and pause from push notification
@Lindsay-Needs-Sleep Lindsay-Needs-Sleep mentioned this issue Nov 2, 2020
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants