title: ChromeCast - Not receiving call backs when remote has finished streaming Videos
body: <p>I have one activity where i inflate different views (instead of activities).The issue i'm facing is, I'm unable to resume play locally when i explicitly disconnect <strong>Sender</strong> from the <strong>VideoCastControllerActivity</strong>. But from within my app it gets disconnected and resumes playback.
  Here is the snippet.</p>
  
  <pre><code>private void initializeChromecast() {
  
      mCastManager = CastApplication.getCastManager(CastApplicationMainActivity.this);
      mMini = (MiniController) findViewById(R.id.miniController1);
      mCastManager.addMiniController(mMini);
      mCastManager.reconnectSessionIfPossible(CastApplicationMainActivity.this, false);
  
      // -- Adding MiniController
      mMini = (MiniController) findViewById(R.id.miniController1);
      mCastManager.addMiniController(mMini);
      initRemoteMediaController();
      mCastConsumer = new VideoCastConsumerImpl() {
  
          @Override
          public void onCastDeviceDetected(final RouteInfo info) {
  
              /** Show tutorial if first time user and */
  
              boolean flag = pref.getBoolean("Eros_now_ftu", true);
              if (flag) {
                  showFtu();
                  editor.putBoolean("Eros_now_ftu", false);
                  editor.commit();
              }
  
          }
  
          @Override
          public void onApplicationConnected(ApplicationMetadata appMetadata, String sessionId, boolean wasLaunched) {
              // TODO Auto-generated method stub
              super.onApplicationConnected(appMetadata, sessionId, wasLaunched);
              isCastReceiverLaunched = wasLaunched;
  
          }
  
          @Override
          public void onApplicationDisconnected(int errorCode) {
              // TODO Auto-generated method stub
              super.onApplicationDisconnected(errorCode);
          }
  
          @Override
          public void onCastAvailabilityChanged(boolean castPresent) {
              // TODO Auto-generated method stub
              super.onCastAvailabilityChanged(castPresent);
              isCastDevicePresent = castPresent;
              // updateActionBar(isCastDevicePresent);
          }
  
          public void onRemoteMediaPlayerStatusUpdated() {
              super.onRemoteMediaPlayerStatusUpdated();
              MediaStatus status = mRemoteMediaPlayer.getMediaStatus();
              int state = status.getPlayerState();
              if (state == MediaStatus.IDLE_REASON_FINISHED) {
                  NowPlayingView nowPlaying = NowPlayingView.getInstance(mParent);
                  getDefaultParentLayout().removeAllViews();
                  getDefaultParentLayout().addView(nowPlaying.getCurrentView());
                  // Push data
                  pushToViewStack(nowPlaying);
  
              }
          }
  
          @Override
          public void onDisconnected() {
  
              // mMediaRouter.selectRoute(mMediaRouter.getDefaultRoute());
              /*
               * if (!mParent.getParentActivty().getActionBar().isShowing() &amp;&amp; isCastDevicePresent) {
               * mParent.getParentActivty().getActionBar().show(); }
               */
              try {
                  MediaInfo media = mCastManager.getRemoteMediaInformation();
                  playMediaLocally(media);
              } catch (TransientNetworkDisconnectionException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              } catch (NoConnectionException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
          }
      };
  }
  </code></pre>
  
  <p>Implementing <strong>RemoteMediaPlayerStatusUpdated()</strong></p>
  
  <p>I'm not receiving any callbacks to <strong>onDisconnected</strong> and <strong>onRemoteMediaPlayerStatusUpdated()</strong></p>
  
  <pre><code>private void initRemoteMediaController() {
  
      if (null == mRemoteMediaPlayer)
          mRemoteMediaPlayer = new RemoteMediaPlayer();
      mRemoteMediaPlayer.setOnStatusUpdatedListener(new RemoteMediaPlayer.OnStatusUpdatedListener() {
  
          @Override
          public void onStatusUpdated() {
              MediaStatus status = mRemoteMediaPlayer.getMediaStatus();
              int state = status.getPlayerState();
              if (state == MediaStatus.IDLE_REASON_FINISHED) {
                  NowPlayingView nowPlaying = NowPlayingView.getInstance(mParent);
                  getDefaultParentLayout().removeAllViews();
                  getDefaultParentLayout().addView(nowPlaying.getCurrentView());
                  // Push data
                  pushToViewStack(nowPlaying);
  
              }
          }
      });
  
  }
  </code></pre>
  
  <p>Other MediaRouter Setup</p>
  
  <pre><code>public void onResume() {
      Log.d(TAG, "onResume() was called");
      mCastManager = CastApplication.getCastManager(this);
      if (null != mCastManager) {
          mCastManager.addVideoCastConsumer(mCastConsumer);
          mCastManager.incrementUiCounter();
      }
  
      super.onResume();
  </code></pre>
  
  <p>}</p>
  
  <pre><code>public void onPause() {
      mCastManager.decrementUiCounter();
      mCastManager.removeVideoCastConsumer(mCastConsumer);
      super.onPause();
  
      /*
       * if(mImageFetcher != null){ mImageFetcher.setExitTasksEarly(true); mImageFetcher.flushCache(); }
       */
  }
  </code></pre>