title: Android VideoView - How to play videos in sequence
body: <p>I'm trying to develop an android application that plays more than one video in one videoview. When one is finished, the second has to start and so on.</p>
  
  <p>My videos are stored in the raw folder of the project,
  to get their filenames i do:</p>
  
  <pre><code>Field[] fields = R.raw.class.getFields();
  
          final List&lt;String&gt; videoNames = new ArrayList&lt;String&gt;() ;
  
          for(Field field: fields){
              videoNames.add(field.getName());
          }
  </code></pre>
  
  <p>then i set the first one's path to my video view</p>
  
  <pre><code> videoUri = Uri.parse("android.resource://" + getActivity().getPackageName() + "/" 
                              + videoNames.get(0));
  
  myVideoView.setVideoURI(videoUri);
  </code></pre>
  
  <p>to play the others </p>
  
  <pre><code>    myVideoView.setOnCompletionListener(new   MediaPlayer.OnCompletionListener() {
  
              @Override
              public void onCompletion(MediaPlayer mp) {
  
  
                   videoUri = Uri.parse("android.resource://" + getActivity().getPackageName() + "/" 
                              + videoNames.get(VideoI));
                   myVideoView.setVideoURI(videoUri);
  
                   myVideoView.start();
  
                   if(VideoI==videoNames.size()-1)
                   {
                       VideoI=0;
                   }
                   else{
                       VideoI++;
                   }
              }
          });
  </code></pre>
  
  <p>BUT...</p>
  
  <p>every time that i try this code in real device, i get the same error 
  "can't play video" when the first video is finished...</p>
  
  <p>all the videos are .mp4 file recorded with the same device that i use for develop...</p>
  
  <p>any ideas? or other ways to play more videos in sequence? 
  I looked for a solution everywhere but i couldn't find it..</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>DID IT!! ok.. the error was so silly.. thank you all for the helpful answers.</p>
  
  <p>the error was in the path i was looking for ("these are not the paths your looking for" cit.)  </p>
  
  <p>as i wrote, the videos are stored in raw folder..
  i was using</p>
  
  <pre><code> videoUri = Uri.parse("android.resource://" + MainActivity.ctx.getPackageName() + "/
                                      + videoNames.get(VideoI));
  </code></pre>
  
  <p>adding raw folder in path </p>
  
  <pre><code>videoUri = Uri.parse("android.resource://" + MainActivity.ctx.getPackageName() + "/raw/" 
                                      + videoNames.get(VideoI));
  </code></pre>
  
  <p>it finally worked.. as i wrote.. it was a silly.. </p>