title: Audio Player - How to play next and prev songs using ListView
body: <p>Writing a small Audio player in which i want to allow user to play prev and next songs whenever user do tap on respective button, i am using listview for listing all the songs</p>
  
  <pre><code>private int currentSongIndex = 0;
  
  listview.setOnItemClickListener(new OnItemClickListener() {
  
  @Override
  public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int position,
      long id) {                  
  
       strNURL = videoMovieArrayList.get(position).getUrl().toString();
       strNTITLE = videoMovieArrayList.get(position).getTitle().toString();
  
               if(mediaPlayer!=null &amp;&amp; mediaPlayer.isPlaying())
                     try {
                             mediaPlayer.stop();
                          } catch (Exception e) {     
                      }
                            play(arg1);
                            textTrack.setText(strNTITLE);
                          }
                   });        
              }
  
      public void play(View view){    
         mediaPlayer = new MediaPlayer();
         mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
          try {
              mediaPlayer.setDataSource(strNURL);
          } catch (IllegalArgumentException e) {
          .......................
  
        mediaPlayer.setOnCompletionListener(new OnCompletionListener() {
  
          @Override
          public void onCompletion(MediaPlayer arg0) {
              // TODO Auto-generated method stub
              pauseButton.setEnabled(false);
              playButton.setEnabled(true);                
             }
         });
     }
  
     public void prev(View view){ 
          Toast.makeText(MusicTrackActivity.this, "Previous song !", Toast.LENGTH_LONG).show();
  
         if(currentSongIndex &gt; 0){
            // play(currentSongIndex - 1);
             currentSongIndex = currentSongIndex - 1;
         }else{
             // play last song
             // playSong(videoMovieArrayList.size() - 1);
             currentSongIndex = videoMovieArrayList.size() - 1;
         }
     }
  
     public void next(View view){ 
          Toast.makeText(MusicTrackActivity.this, "Next song !", Toast.LENGTH_LONG).show();
  
          if(currentSongIndex &lt; (videoMovieArrayList.size() - 1)){        
               // play(currentSongIndex + 1);
              currentSongIndex = currentSongIndex + 1;
          }else{          
              // play(0);
              currentSongIndex = 0;
          }
     }
  </code></pre>
  
  <p>So now my query is How can i switch to Next song, whenever user do tap on next button, as you can see in above code, i am simply showing Toast message</p>