48

I am attempting to write a RemotePlaybackClient sample app, in part because the one published by Google crashes aapt.

I can get RemotePlaybackClient to support play(), and it plays back a video on a Chromecast.

However, when I call stop(), to stop playback of the video, while the Chromecast does stop playback (showing a black screen with a cast icon centered), the SessionActionCallback that I pass into the stop() call does not get called with onResult():

  private void stop() {
    logToTranscript(getActivity().getString(R.string.stop_requested));

    SessionActionCallback stopCB=new SessionActionCallback() {
      @Override
      public void onResult(Bundle data, String sessionId,
                           MediaSessionStatus sessionStatus) {
        logToTranscript(getActivity().getString(R.string.stopped));
        isPlaying=false;
        isPaused=false;
        getActivity().supportInvalidateOptionsMenu();
        endSession();
      }
    };

    client.stop(null, stopCB);
  }

The same thing happens if I try pause() -- the SessionActionCallback passed to pause() is not invoked.

The sample code published by Google shows that these callbacks should be invoked, but, again, I can't get that to compile successfully.

Does anyone know under what circumstances the SessionActionCallback would not work, while the ItemActionCallback used with play() would work?

UPDATE

I have filed issue 66996 and issue 67032, the latter of which is specifically the problem I am seeing here, as I run into this same problem with the official sample app.

8
  • I did get the sample to compile in Eclipse, and it too is not receiving anything on its SessionActionCallback when stop() or pause() is called. Commented Mar 11, 2014 at 18:31
  • What receiver are you using?
    – Ali Naddaf
    Commented Mar 12, 2014 at 0:06
  • @AliNaddaf: I am using a Chromecast from a hardware standpoint. RemotePlaybackClient does not specify a receiver, near as I can tell, so presumably under the covers Chromecast is using the default receiver. Commented Mar 12, 2014 at 10:50
  • The first time I call stop, from the sample app, a MediaRouteProviderProtocol.SERVICE_MSG_GENERIC_FAILURE occurs, but pressing it once more will call SessionActionCallback.onResult twice. So, it seems like RegisteredMediaRouteProvider.sendControlRequest isn't being called the first time around, for some reason.
    – adneal
    Commented Mar 26, 2014 at 17:17
  • @adneal: Where you are seeing SERVICE_MSG_GENERIC_FAILURE, since stop() is void? Commented Mar 26, 2014 at 17:24

1 Answer 1

1

I beleive all Answer reside on how you make connection. Because in google code ,code says that client which you had made shold not leave session and should not be null.

if (!mClient.hasSession()) {
   // ignore if no session
   return;
}

/*********Rest of the code would be unreachable***********/

@Override
public void pause() {
    if (!mClient.hasSession()) {
        // ignore if no session
        return;
    }
    if (DEBUG) {
        Log.d(TAG, "pause");
    }
    mClient.pause(null, new SessionActionCallback() {
        @Override
        public void onResult(Bundle data, String sessionId, MediaSessionStatus sessionStatus) {
            logStatus("pause: succeeded", sessionId, sessionStatus, null, null);
            if (mCallback != null) {
                mCallback.onPlaylistChanged();
            }
        }
        @Override
        public void onError(String error, int code, Bundle data) {
            logError("pause: failed", error, code);
        }
    });
}
2
  • I am sorry, but I do not understand your answer. Commented Jul 31, 2014 at 16:23
  • I think he's saying that he thinks you don't have a session, so it's hitting that return statement. Commented Aug 28, 2014 at 21:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.