So how to provide custom routes using MediaRouteProviderService with cast SDK v3
In v3, device discovery is now being handled by CastContext. In v3 Configure device discovery, it states that:
Device discovery is completely managed by the
CastContext.
When initializing the CastContext, the sender app specifies the
receiver application ID, and can optionally request namespace
filtering by setting supportedNamespaces in
CastOptions.
CastContext holds a reference to the MediaRouter internally, and will
start the discovery process when the sender app enters the foreground,
and stop when the sender app enters background.
class CastOptionsProvider implements OptionsProvider {
public static final String CUSTOM_NAMESPACE = "urn:x-cast:custom_namespace";
@Override
public CastOptions getCastOptions(Context appContext) {
List<String> supportedNamespaces = new ArrayList<>();
supportedNamespaces.add(CUSTOM_NAMESPACE);
CastOptions castOptions = new CastOptions.Builder()
.setReceiverApplicationId(context.getString(R.string.app_id))
.setSupportedNamespaces(supportedNamespaces)
.build();
return castOptions;
}
@Override
public List<SessionProvider> getAdditionalSessionProviders(Context context) {
return null;
}
}