Bug 28858 - Google Chromecast(Google Play Services) - RemoteMediaPlayer.MediaStatus always returns null
Summary: Google Chromecast(Google Play Services) - RemoteMediaPlayer.MediaStatus alway...
Alias: None
Product: Components
Classification: Xamarin
Component: Xamarin Components ()
Version: Production (addons.xamarin.com)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jon Dick
Depends on:
Reported: 2015-04-07 14:13 UTC by Jon Douglas [MSFT]
Modified: 2015-04-15 16:34 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Jon Douglas [MSFT] 2015-04-07 14:13:33 UTC

It seems that there might be an issue with the current bindings to the Google Chromecast section within the Google Play Services component.

I've isolated the problem to the callbacks on RemoteMediaPlayer not being called when they should (if i compare my code to some Android apps (written in Java)).

Even if i call the method SetOnStatusUpdatedListener on my RemoteMediaPlayer, the callback is never called. Even if i call RequestStatus on the RemoteMediaPlayer, the callback is never called. I have 3 possible callbacks that can be called (OnStatusUpdated, OnMetadataUpdated and OnResult (when I call the Load method)) and none of them are ever called so I'm beginning to think that there could be a problem with the bindings on the callbacks for the RemoteMediaPlayer class but I cannot be certain.

C# Sample:

mediaPlayer = new AndroidMediaPlayer(this);
mediaPlayer.SetOnStatusUpdatedListener(new AndroidMediaPlayerOnStatusUpdated(this, mediaPlayer));


    internal class AndroidMediaPlayerOnStatusUpdated : Java.Lang.Object, RemoteMediaPlayer.IOnStatusUpdatedListener
        public AndroidMediaPlayerOnStatusUpdated(MainActivity aController, AndroidMediaPlayer aMediaPlayer)
            controller = aController;
            mediaPlayer = aMediaPlayer;

        public void OnStatusUpdated()
            controller.LogMessage("In OnStatusUpdated() of AndroidMediaPlayerOnStatusUpdated");

        #region Private
        private readonly MainActivity controller;
        private readonly AndroidMediaPlayer mediaPlayer;

Attempting to receive the status:

mediaPlayer.RequestStatus(googleApiClient).SetResultCallback(new RequestStatusResultCallback(this));

Java Sample:

mRemoteMediaPlayer = new RemoteMediaPlayer();
mRemoteMediaPlayer.setOnStatusUpdatedListener(new RemoteMediaPlayer.OnStatusUpdatedListener() {
public void onStatusUpdated() {
MediaStatus mediaStatus = mRemoteMediaPlayer.getMediaStatus();
isPlaying = mediaStatus.getPlayerState() == MediaStatus.PLAYER_STATE_PLAYING;

*Version Information

Google Play Services - 22.0.2

*Further Reading


Comment 2 Jon Dick 2015-04-15 16:34:51 UTC
This is not a bug, but the reason your OnStatusUpdated is never called is because you're registering a custom namespace in the CastClass.CastApi.SetMessageReceivedCallbacks calls you make, but the RemoteMediaPlayer is expecting to see messages with its own namespace (mediaPlayer.Namespace which i think is "urn:x-cast:com.google.cast.media"), and is failing to parse the messages the receiver app is returning about media state, since they are coming back with your own custom namespace.

So, change your sample's calls to CastClass.CastApi.SetMessageReceivedCallbacks (googleApiClient, mediaPlayer.Namespace, mediaPlayer), remember there's two places in your code that need to be changed, and you should be all set!