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.
SessionActionCallback
whenstop()
orpause()
is called.RemotePlaybackClient
does not specify a receiver, near as I can tell, so presumably under the covers Chromecast is using the default receiver.stop
, from the sample app, aMediaRouteProviderProtocol.SERVICE_MSG_GENERIC_FAILURE
occurs, but pressing it once more will callSessionActionCallback.onResult
twice. So, it seems likeRegisteredMediaRouteProvider.sendControlRequest
isn't being called the first time around, for some reason.SERVICE_MSG_GENERIC_FAILURE
, sincestop()
isvoid
?