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

Media update listener not being called #51

Open
grahamharper opened this issue Jan 15, 2015 · 5 comments
Open

Media update listener not being called #51

grahamharper opened this issue Jan 15, 2015 · 5 comments

Comments

@grahamharper
Copy link

I've been debugging an issue with my app that relies on the a listener function that gets called when the current media is updated.

My problem is this listener is not getting called.

Once media is successfully loaded I add a listener to it using .addUpdateListener().

Here are the relevant parts of my code:

castService.session.loadMedia(request, onMediaDiscovered.bind(this, 'loadMedia'), onMediaError);

function onMediaDiscovered(how, mediaSession) {
    console.log('new media session ID:' + mediaSession.mediaSessionId);
    castService.currentMediaSession = mediaSession;
    castService.currentMediaSession.addUpdateListener(onMediaStatusUpdate);
}

function onMediaStatusUpdate(isAlive) {
    console.log('onMediaStatusUpdate was called);
}

onMediaStatusUpdate() doesn't seem to fire in @Vaporexpress sample project either https://github.com/Vaporexpress/Cordova-CastVideos-chrome
I just checked by adding a console.log() inside the function.

@Vaporexpress
Copy link
Contributor

It's not true.
Plug your device by usb, open chrome "inspect devices" (on Tools? [Sorry my language is Spanish, I don't know if It's "Tools" the named option in English])
Open the sample app on your device, choose tab "Inspect with Chrome Developer Tools" and click on "Inspect".
Go to page "Developer Tools" opened and in sources "castVideos.js" add breakpoints on lines 412,462,555 and 564. The line 462 is inside the callback "onMediaStatusUpdate".
Click on icon "chomecast" on the sample app, for each breakpoint look the stoped point and click continue.
You'll see that after discovery "onMediaStatusUpdate" is called.
If you make a click on progress bar an do a seek request, after that "onMediaStatusUpdate" is called.
And so on.

@grahamharper
Copy link
Author

Hmm, I tried that and every breakpoint is being hit except line 462. Very strange. Any idea why that might be happening for me?

@Vaporexpress
Copy link
Contributor

I don't know.
Try running the code through a localhost server, on this way sample load and execute chrome cast extension instead of the plugin interface and look at the breakpoints.
"onMediaStatusUpdate" log on console "updating media" message if you don't add breakpoints.

@grahamharper
Copy link
Author

Thanks for your help so, I really appreciate it, I've been trying to crack this for days.

When I run your code on localhost in Chrome (using the cast extension) the bug is not present, everything behaves as expected.
When I run the compiled version of your app from the dist directory in your repo the bug isn't present.
When I build your app myself using a new cordova project the bug is present. That would indicate to me the bug is being introduced somewhere in the build process or a dependancy?

@axten
Copy link
Contributor

axten commented Aug 12, 2015

same probleme here, update listener is never called...
are there any solutions to fix that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants