title: Android - play mp3 from byte[] array
body: <p>I have byte[] array, which contains mp3 file. Is there any way how to play mp3 file without creating temporary file?</p>
  
  <p>Thanks</p>
  
  <p><strong>Edited:</strong></p>
  
  <p>I have tried temporary file approach:</p>
  
  <pre><code>                File tempMp3 = File.createTempFile("test", ".mp3", getCacheDir());
  
                  //tempMp3.deleteOnExit();
                  FileOutputStream fos = new FileOutputStream(tempMp3);
                  fos.write(bytes);
                  fos.close();
  
                  mediaPlayer = MediaPlayer.create(getApplicationContext(),Uri.fromFile(tempMp3));
                  mediaPlayer.start();
  </code></pre>
  
  <p>And I am still getting the NullPointerException. I am writing byte array (called bytes) to file, I am keeping its referrence and using it. But still getting NPE. Do you know where is the mistake?</p>