title: How to intercept the “Cannot play video” dialog while working with streaming or networked video?
body: <p>How to intercept the "Cannot play video" dialog while working with streaming or networked video?</p>
  
  <p>I tried the following and was able to display my custom error message. But on top of that I am still getting Android MediaPlayer error dialog "Cannot play video".</p>
  
  <p>I have implemented <code>setOnErrorListener</code> for MediaPlayer and overwrote the <code>onError</code> method with logic to show my error message and I am returning <code>true</code> to let Android know I am handling this error. My code is as follows</p>
  
  <pre><code>mediaPlayer.setOnErrorListener(new OnErrorListener() {
      @Override
      public boolean onError(MediaPlayer mp, int what, int extra) {
          if (!mediaActivity.isFinishing()) {
              mVideoView.stopPlayback();
              mediaPlayer.release();
              showErrorDialog(false);
          }
          return true;
      }
  });
  </code></pre>