title: Android MediaPlayer Streaming Error: 100: MEDIA_ERROR_SERVER_DIED
body: <p>I've developed an app which takes an advantage of the native Android's MediaPlayer. The source code of my class making use of Media Player is below.</p>
  <p>The problem is that only on some devices after some miliseconds of playback (I hear only voice, the screen remains black) I keep getting <code>error(100,0)</code> which according to the <a href="http://developer.android.com/reference/android/media/MediaPlayer.html#MEDIA_ERROR_SERVER_DIED" rel="noreferrer">documentation</a> says</p>
  <blockquote>
  <p><code>public static final int MEDIA_ERROR_SERVER_DIED</code></p>
  <p>Media server died. In this case, the application must release the MediaPlayer object and instantiate a new one.</p>
  </blockquote>
  <p>On forums I've found out that I need to reset the player every time I get it... but I get it after just a short moment and then it dies forever. I cannot reset the player every second since playback is useless. I cannot get why some devices have this problem and others not. The one that I know has Android OS &gt; 4.0.</p>
  <p>Of course, first <code>init()</code> and then <code>showVideo()</code> are getting called. The last <code>onError</code> with code 100 is then called. What's a potential solution to make the streams run continuously and not break?</p>
  <pre><code>public class NativePlayer extends Player implements OnBufferingUpdateListener,
          OnCompletionListener, OnErrorListener, OnInfoListener {
  
      private VideoView videoview;
      private PlayerListener listener;
      private MainActivity context;
  
      private final Logger logger = LoggerFactory.getLogger(NativePlayer.class);
  
      @Override
      public void init(MainActivity activity) {
          this.videoview = (VideoView) activity.findViewById(R.id.video);
          context = activity;
      }
  
      @Override
      public void showVideo(final String url, final PlayerListener _listener) {
          listener = _listener;
          videoview.setVisibility(View.VISIBLE);
          try {
              Uri video = Uri.parse(url);
              videoview.setVideoURI(video);
          } catch (Exception e) {
              logger.error(&quot;Error playing video&quot;, e);
              listener.onVideoError();
              return;
          }
  
          videoview.setOnCompletionListener(this);
          videoview.setOnErrorListener(this);
          videoview.requestFocus();
  
          videoview.setOnPreparedListener(new OnPreparedListener() {
              public void onPrepared(MediaPlayer mp) {
                  videoview.start();
                  if (listener != null) {
                      listener.onVideoStarted();
                  }
              }
          });
      }
  
      @Override
      public void onStop() {
          stop();
      }
  
      private void stop() {
          if (videoview == null) {
              return;
          }
          if (videoview.isPlaying()) {
              videoview.stopPlayback();
          }
      }
  
      @Override
      public void onDestroy() {
      }
  
      @Override
      public void onCompletion(MediaPlayer mp) {
          stop();
      }
  
      @Override
      public boolean onError(MediaPlayer mp, int what, int extra) {
          if (listener != null) {
              listener.onVideoError();
          }
          return false;
      }
  
      @Override
      public boolean onInfo(MediaPlayer mp, int what, int extra) {
          if (listener != null) {
              listener.onInfo(what, extra);
          }
          return false;
      }
  
      @Override
      public void onBufferingUpdate(MediaPlayer mp, int percent) {
          if (listener != null) {
              listener.onBufferingUpdate(percent);
          }
      }
  }
  </code></pre>