Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RemotePlaybackClient, stop() not getting callback

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.

like image 625
CommonsWare Avatar asked Mar 11 '14 16:03

CommonsWare


1 Answers

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);         }     }); } 
like image 106
DeepakPanwar Avatar answered Oct 04 '22 23:10

DeepakPanwar