title: How to play a media file using loop with some delay?
body: <p>I am trying to play a raw media file using a loop. I have written a synchronized method to play the media file. This is working on emulator but not on real device.</p>
  
  <p>I have created a simple bean for Question for which sound needs to be played.</p>
  
  <pre><code>public class Question {
  private String mQuestionString;
  private int mSoundFile;
  private int mAnswer;
  private int mQuestionNo;
  
  public Question() {
  
      mQuestionNo = 0;
      mQuestionString = "";
      mSoundFile = 0;
      mAnswer = 0;
  }
  
  public Question(int mQuestionNo, String mQuestionString, int mSoundFile,
          int mAnswer) {
      super();
      this.mQuestionNo = mQuestionNo;
      this.mQuestionString = mQuestionString;
      this.mSoundFile = mSoundFile;
      this.mAnswer = mAnswer;
  }
  
  public String getQuestionString() {
      return mQuestionString;
  }
  
  public void setQuestionString(String mQuestionString) {
      this.mQuestionString = mQuestionString;
  }
  
  public int getSoundFile() {
      return mSoundFile;
  }
  
  public void setSoundFile(int mSoundFile) {
      this.mSoundFile = mSoundFile;
  }
  
  public int getAnswer() {
      return mAnswer;
  }
  
  public void setAnswer(int mAnswer) {
      this.mAnswer = mAnswer;
  }
  
  public int getQuestionNo() {
      return mQuestionNo;
  }
  
  public void setQuestionNo(int mQuestionNo) {
      this.mQuestionNo = mQuestionNo;
  }
  
  @Override
  public String toString() {
      return "Question " + mQuestionNo + ". " + mQuestionString;
  }
  
  }
  </code></pre>
  
  <p>This is my code in the activity</p>
  
  <pre><code>public class LQActivity extends Activity{
  
      private Vector&lt;Question&gt; mQuestions = null;
  private TextView tvQuestion = null;
  private Button btnSubmit = null;
  private Button btnNext = null;
      ...
  
    private void prepareQuestions() {
      // TODO Auto-generated method stub
      mQuestions = new Vector&lt;Question&gt;();
      mQuestions.add(new Question(1, "Count the number of the Tabala played",
              R.raw.q1, 5));
      mQuestions.add(new Question(2,
              "Count the number of the persons visited temple", R.raw.q2, 3));
      mQuestions
              .add(new Question(3, "Count the number of frogs", R.raw.q3, 6));
      mQuestions.add(new Question(4,
              "Count the number of the cuckoo on the tree", R.raw.q4, 8));
      mQuestions.add(new Question(5, "Count the number of the flute played",
              R.raw.q5, 7));
  
  }
  
  private synchronized void playQuestion(Question question) {
  
  
      mMediaPlayer = MediaPlayer.create(this, question.getSoundFile());
  
      mMediaPlayer.start();
      try {
          Thread.sleep(3000);
      } catch (InterruptedException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
          if (mMediaPlayer != null) {
              mMediaPlayer.release();
          }
      }
              mMediaPlayer.release();
          }
  
  }
  </code></pre>
  
  <p>The problem is <code>mMediaPlyer.create()</code> is returning null </p>
  
  <p>I am not getting the exact problem. your help is appreciated. Thanks in advance...</p>