@Override
  protected Builder getCastOptionBuilder(CastDevice device) {

    Builder builder = Cast.CastOptions.builder(mSelectedCastDevice, new CastListener());
    if (isFeatureEnabled(FEATURE_DEBUGGING)) {
      builder.setVerboseLoggingEnabled(true);
    }
    return builder;
  }
  /** Connects to the device with all callbacks and things */
  private void connectToDevice() {
    try {
      Cast.CastOptions.Builder apiOptionsBuilder = Cast.CastOptions.builder(this.device, this);

      this.mApiClient =
          new GoogleApiClient.Builder(this.cordova.getActivity().getApplicationContext())
              .addApi(Cast.API, apiOptionsBuilder.build())
              .addConnectionCallbacks(this)
              .addOnConnectionFailedListener(this)
              .build();

      this.mApiClient.connect();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }