Is it possible to use the MiniControllerFragment with a custom MediaRouteProvider?

770 views Asked by At

Is it possible to have Google's cast MiniControllerFragment work with my custom MediaRouteProvider?

The reason I ask: The mini-controller button UI doesn't appear when I cast to my custom MediaRouteProvider. I notice MiniControllerFragment[1] uses UIMediaController.

I read through the code of UIMediaController. It looks like UIMediaController is driven by events from the SessionManager singleton. The UIMediaController subscribes to the SessionManager, but only handles Sessions of class "CastSession"[4].

I'm not sure if it's possible for me to extend/instantiate a CastSession in my SessionProvider (I currently create a class extended from cast.framework.Session [2]).

It looks rather tricky to instantiate a CastSession object[3], it's constructor has a long list of classes, some of which I can't seem to get an instance of from anywhere.

Thanks, Rik.


Notes

[1] MiniControllerFragment docs: https://developers.google.com/android/reference/com/google/android/gms/cast/framework/media/widget/MiniControllerFragment

[2] Session / CastSession docs: https://developers.google.com/android/reference/com/google/android/gms/cast/framework/Session

[3] CastSession constructor, according to decompiled .class file. Requires instances of undocumented classes. No factory method seems to exist:

public CastSession(
   Context var1, 
   String var2, 
   String var3, 
   CastOptions var4, 
   CastApi var5,   //< Can't instantiate this - Rik.
   zzws var6,      //< Not sure what class that is! - Rik.
   zzxe var7       //< Not sure what class that is! - Rik.
) 

[4] Delegate function handling onSessionStarted() event from Session Manager. Only interested in CastSession sessions:

private void zza(Session var1) {
   if(!this.isActive() && var1 instanceof CastSession && var1.isConnected()){
       // Does work with RemoteMediaClient here ...
   }
}
0

There are 0 answers