felnanuke2 / flutter_google_cast

BSD 3-Clause "New" or "Revised" License
4 stars 4 forks source link

GoogleCastDiscoveryManager.instance.devicesStream returns empty array #5

Open astheras opened 1 year ago

astheras commented 1 year ago

can you help me? i have created a simple class, but GoogleCastDiscoveryManager.instance.devicesStream returns always []. At the same time, youtube app found all nearby devices.

class CastService {
  CastService() {
    const String appId = GoogleCastDiscoveryCriteria.kDefaultApplicationId;
    late final GoogleCastOptions options;
    if (Platform.isIOS) {
      options = IOSGoogleCastOptions(
        GoogleCastDiscoveryCriteriaInitialize.initWithApplicationID(appId),
      );
    } else if (Platform.isAndroid) {
      options = GoogleCastOptionsAndroid(
        appId: appId,
      );
    }
    GoogleCastContext.instance.setSharedInstanceWithOptions(options);
  }

  Stream<List<GoogleCastDevice>> loadAvailableDevice({
    Duration timeout = const Duration(seconds: 5),
  }) {
    return GoogleCastDiscoveryManager.instance.devicesStream;
  }
}

added <meta-data android:name= "com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME" android:value="GoogleCastOptionsProvider" /> to manifest.

Flutter SDK 3.10.6 Dart SDK 3.0.6 (Flutter)

skalex4 commented 1 year ago

+1,

Same here. I also tried running the example app, that also didn't work.

priyank-dt commented 1 year ago

Hello, @skalex4 @astheras

Make changes as below in your AndroidManifest.xml file and Check

<meta-data
     android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
     android:value="com.felnanuke.google_cast.GoogleCastOptionsProvider" />

This is working on My implementation.