Android - Play mp3 directly from the input stream without writing to temporary files

I am creating an input stream for buffering and an mp3 stream from the cloud.

URL url = new URL("http://xxxx.yyy.com/Demo.mp3");

InputStream inputStream = url.openStream();

Now, how can I play mp3 from a media player without using a temporary file to save and read from it? I am developing for Android Lollipop

+4
source share
3 answers

This problem persists today! Check out these links https://code.google.com/p/android/issues/detail?id=29870 and

http://www.piterwilson.com/blog/2014/03/11/android-mediaplayer-not-quite-there-yet/. MediaPlayer, mp3-, , MediaPplayer . , mp3- PCM, AudioTrack Mediaplayer , :

+1

, MediaPlayer URL-. . setDataSource MediaPlayer.

EDIT: , , . AudioTrack. SO . .

+1

, MediaPlayer, ParcelFileDescriptor # createPipe() ( API 9 ) MediaPlayer # setDataSource (java.io.FileDescriptor).

():

ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe();
FileDescriptor fd = pipe[0].getFileDescriptor();
mediaPlayer.setDataSource(fd);
OutputStream out = new ParcelFileDescriptor.AutoCloseOutputStream(pipe[1]);

, , MediaPlayer. , FIFO ( , TCP), , ( ).

0

All Articles