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 this
public void writeSam
Try this :
private void playMp3(byte[] mp3SoundByteArray)
{
try
{
File path=new File(getCacheDir()+"/musicfile.3gp");
FileOutputStream fos = new FileOutputStream(path);
fos.write(mp3SoundByteArray);
fos.close();
MediaPlayer mediaPlayer = new MediaPlayer();
FileInputStream fis = new FileInputStream(path);
mediaPlayer.setDataSource(getCacheDir()+"/musicfile.3gp");
mediaPlayer.prepare();
mediaPlayer.start();
}
catch (IOException ex)
{
String s = ex.toString();
ex.printStackTrace();
}
}