title: Android how can play song for 30 seconds only in mediaPlayer
body: <p>I am working on Android , I am creating a player for audio songs. I want to play a song only for just 30 seconds. After that, player must be closed. It should be start again, if I press <code>START</code> button again. </p>
  
  <p>This is the code for creating a media player:</p>
  
  <pre><code>    MediaPlayer mediaPlayer = new MediaPlayer();
      public void songPreview(String songURL){
  
          try{
          mediaPlayer=new MediaPlayer();
          mediaPlayer.setDataSource(songURL);
               mediaPlayer.prepare();
               mediaPlayer.start();
  
          } catch(Exception ex){
              ex.printStackTrace();
          }
      }
  </code></pre>
  
  <p>Please suggest me what code should I use to play my song only for 30 seconds after that it will stop, and if I want to play again then I have to press start button.</p>
  
  <p>Note: Please provide me logic to stop media player after 30 second.</p>
  
  <p>Thank you in advance.</p>