I'm developing an android app that will play mp3 files. However the mp3 files are encrypted on the sd card or sqlite. Either ways, after decryption, i'll have a stream of bytes. How do i play them? MediaPlayer does not take inputstream as parameter, so i cannot consider that.
I think you need to store the stream to file system; then you could try using setDataSource
method of MediaPlayer
FileInputStream rawmp3file= new FileInputStream(yourByteArrayAsMp3File);
mediaPlayer.setDataSource(rawmp3file.getFD());
If you could switch to PCM audio source, have a look at AudioTrack class.
The AudioTrack class manages and plays a single audio resource for Java applications. It allows to stream PCM audio buffers to the audio hardware for playback. This is achieved by "pushing" the data to the AudioTrack object using one of the write(byte[], int, int) and write(short[], int, int) methods.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With