title: Android - Why does my application keep bringing up the "Video can't be played screen"
body: <p>is there something wrong with the code? Some reason it won't be played?</p>
  
  <pre><code>import java.io.File;
  import android.app.Activity;
  import android.content.Intent;
  import android.media.MediaPlayer;
  import android.media.MediaPlayer.OnCompletionListener;
  import android.media.MediaPlayer.OnPreparedListener;
  import android.net.Uri;
  import android.os.Bundle;
  import android.os.Environment;
  import android.view.MotionEvent;
  import android.widget.VideoView;
  
  public class Video extends Activity implements OnCompletionListener, OnPreparedListener {
  
          static private final String pathToFile ="com.chich.res.drawable-  hdpi.troopers.3gp";  // Video source file
         private VideoView videoPlayer;
  
         /** Called when the activity is first created. */
         @Override
         public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.video);
  
  
        videoPlayer = (VideoView) findViewById(R.id.videoPlayer);   
        videoPlayer.setOnPreparedListener(this);
        videoPlayer.setOnCompletionListener(this);
        videoPlayer.setKeepScreenOn(true);    
        videoPlayer.setVideoPath(pathToFile);
         }
  
  
         /** This callback will be invoked when the file is ready to play */
         @Override
         public void onPrepared(MediaPlayer vp) {
  
  
            if(videoPlayer.canSeekForward()) videoPlayer.seekTo(videoPlayer.getDuration()/5);
            videoPlayer.start();
          }
  
          /** This callback will be invoked when the file is finished playing */
          @Override
          public void onCompletion(MediaPlayer  mp) {
            // Statements to be executed when the video finishes.
            this.finish();    
          }
  
          /**  Use screen touches to toggle the video between playing and paused. */
          @Override
          public boolean onTouchEvent (MotionEvent ev){   
             if(ev.getAction() == MotionEvent.ACTION_DOWN){
                if(videoPlayer.isPlaying()){
                         videoPlayer.pause();
                } else {
                         videoPlayer.start();
                }
                return true;      
             } else {
                 return false;
             }
          }
       }
  </code></pre>