0

I'm building a Chromecast Sender application and I can successfully cast a session. However I can only cast once. When I disconnect my sessionListener callback never fires, which is problematic because that is where I set my sessionUpdate listener. Without that it is not possible to tell when a session ends in order to reset the session and do any clean up, which means I can't recast anything because I have no way of knowing if a session is valid or not.

As far as I can tell the problem is in cast_sender.js which is conveniently obfuscated so I could be wrong.

I'm setting up my ApiConfig as follows:

 apiConfig = new _chrome.cast.ApiConfig(
   sessionRequest,
   _sessionListener.bind(this),
   _receiverListener.bind(this));

_receiverListener is fired as expected and I have debugged cast_sender.js to the point where I can see my function _sessionListener being passed in and set properly on line #837 of cast_sender.js, here:

835 chrome.cast.dd = function(a, c, d, e, f) {
836   this.sessionRequest = a;
837   this.sessionListener = c;
838   this.receiverListener = d;
839   this.autoJoinPolicy = e || chrome.cast.Fb.TAB_AND_ORIGIN_SCOPED;
840   this.defaultActionPolicy = f || chrome.cast.Jb.CREATE_SESSION;
841   this.customDialLaunchCallback = null;
842 };

that function appears to be called on line #2441, here:

2440 b.Wf = function(a) {
2441  this.B && this.B.sessionListener(a.message);
2442 };

I have set a breakpoint there and it is never called. At this point I have reached an impasse, any thoughts?

halfer
  • 19,824
  • 17
  • 99
  • 186
Ben Glasser
  • 3,216
  • 3
  • 24
  • 41
  • Can you reproduce this in CastVideos-chrome-material (https://github.com/googlecast/CastVideos-chrome-material) which uses the SessionListener too? – Ali Naddaf Jul 03 '16 at 21:25
  • I actually think I've solved the problem. I set up my sender based on the CastHelloText-chrome example in github which appears to set the session incorrectly. I will be submitting a pull request for my fix later today. – Ben Glasser Jul 05 '16 at 18:06
  • @AliNaddaf https://github.com/googlecast/CastHelloText-chrome/pull/14 – Ben Glasser Jul 05 '16 at 19:59

1 Answers1

0

I found the source of the problem in the callback passed to the cast.requestSession() function of the example code I copy/pasted here https://github.com/googlecast/CastHelloText-chrome/blob/master/chromehellotext.html#L162

I've submitted a pull request for a fix which resolves the issue here https://github.com/googlecast/CastHelloText-chrome/pull/14 but I doubt it will be pulled in considering that it looks like they have PRs sitting in queue unaddressed for several years.

Ben Glasser
  • 3,216
  • 3
  • 24
  • 41