how to play audio using audiotrack in android
I'm developing an android app that will play mp3 files. However the mp3 files are encrypted on the sd card . Either ways, after decryption, i'll have a stream 开发者_StackOverflow中文版of bytes. I hav used audio track class but unable to play the audio.plz help me. thank you in advance.
You could save the stream to a temporary (mp3) file and then play this file with MediaPlayer
EDIT to address comment:
The file would not be persistent, something like
File temp = File.createTempFile("whatever", "mp3", getCacheDir());
temp.deleteOnExit();
FileOutputStream fStream = new FileOutputStream(temp);
fStream.write(passYourStream);
fStream.close();
FileInputStream fStream2 = new FileInputStream(temp);
yourMediaPlayerInstance.setDataSource(fStream2.getFD());
Hi i think it is useful to you http://www.bogotobogo.com/Android/android24MediaB.html#AudioPlay
精彩评论