title: Android: VideoView sometimes stop playing videos after some time
body: <p>I created an app that plays video continuously from a local (LAN) website. First it loads a text file that contains a list of the videos to be played. Then the app plays each video one after another. It works fine but sometimes it just stops. at random videos. When it is stopped and I open another activity and go back to the previous activity (video) the video plays again. Sometimes I'm able to play through all the videos in the play list and go back to the first one. In short, the app is able to play all the videos (no encoder problem). Here's my code.</p>
  
  <pre><code>    videoView.setOnCompletionListener(new OnCompletionListener() {          
      @Override
      public void onCompletion(MediaPlayer mp) {              
          videourl = pmgr.getNextFile();
          video = Uri.parse(videourl);
          videoView.setVideoURI(video);
          videoView.requestFocus();
          videoView.start();              
      }
  });
  
  videoView.setOnPreparedListener(new OnPreparedListener() {          
      @Override
      public void onPrepared(MediaPlayer mp) {                
          mp.setVolume(actualVolume, actualVolume);
          mp.setVideoScalingMode(MediaPlayer.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING);
      }
  });
  
  
  @Override
  protected void onResume() {
  // TODO Auto-generated method stub
  super.onResume();
  videoView.seekTo(position);
  }
  
  
  
  
  
  
  @Override
  protected void onPause() {
  // TODO Auto-generated method stub
  super.onPause();
  position = videoView.getCurrentPosition();
  }
  </code></pre>