Play Byte array in MediaPlayer - Android
<p>I am trying to play an audio file with the MediaPlayer. I want to play byte array in MediaPlayer. How can I do this? I've checked <a href="http://stackoverflow.com/questions/1972027/android-playing-mp3-from-byte">this</a></p>

<pre><code> public void writeSamples(byte[] samples, int length) 
{
  //  track.write( samples, 0, length);
    File tempMp3;
    try {
    tempMp3 = File.createTempFile("kurchina", ".mp3");
      tempMp3.deleteOnExit();
      FileOutputStream fos = new FileOutputStream(tempMp3);
      fos.write(samples);
      fos.close();
      // Tried reusing instance of media player
      // but that resulted in system crashes...  
      MediaPlayer mediaPlayer = new MediaPlayer();

      // Tried passing path directly, but kept getting 
      // "Prepare failed.: status=0x1"
      // so using file descriptor instead   
      FileInputStream fis = new FileInputStream(tempMp3);
      mediaPlayer.setDataSource(fis.getFD());
      mediaPlayer.prepare();
      mediaPlayer.start();
      } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    }
</code></pre>

<p>But its not playing audio. It is just generating many files in SD Card. And giving this <strong>error</strong>:</p>

<pre><code> 06-06 11:02:59.191: E/MediaPlayer(1831): Unable to to create media player
 06-06 11:02:59.191: W/System.err(1831): java.io.IOException: setDataSourceFD failed.:      status=0x80000000
 06-06 11:02:59.201: W/System.err(1831):  at    android.media.MediaPlayer.setDataSource(Native Method)
 06-06 11:02:59.201: W/System.err(1831):  at   android.media.MediaPlayer.setDataSource(MediaPlayer.java:749)
 06-06 11:02:59.201: W/System.err(1831):  at   org.vinuxproject.sonic.SonicTest$1.run(SonicTest.java:178)
 06-06 11:02:59.201: W/System.err(1831):  at java.lang.Thread.run(Thread.java:1096)
</code></pre>

<p>Please help me. Any kind of help is appreciated.</p>

<p>Thanks</p>
