@Override
        public void onResult(ApplicationConnectionResult result) {

          Status status = result.getStatus();

          if (status.isSuccess()) {
            try {
              ApplicationMetadata metadata = result.getApplicationMetadata();
              ChromecastSession.this.sessionId = result.getSessionId();
              ChromecastSession.this.displayName = metadata.getName();
              ChromecastSession.this.appImages = metadata.getImages();

              ChromecastSession.this.joinSessionCallback.onSuccess(ChromecastSession.this);
              connectRemoteMediaPlayer();
              ChromecastSession.this.isConnected = true;
            } catch (IllegalStateException e) {
              e.printStackTrace();
            } catch (IOException e) {
              e.printStackTrace();
            }
          } else {
            ChromecastSession.this.joinSessionCallback.onError(status.toString());
            ChromecastSession.this.isConnected = false;
          }
        }