I created an app, which gets audio data from a server.
Then I store the data to a file on the sdcard and afterwards play it with the MediaPlayer...
This looks like this:
Using java Syntax Highlighting
- String src = "http://xxx.xxx";
- File f = new File("sdcard", "filename.mpeg");
- URL url = new URL(src);
- HttpURLConnection con = (HttpURLConnection) url.openConnection();
- InputStream in = con.getInputStream();
- FileOutputStream output = new FileOutputStream(f);
- byte[] buffer = new byte[BUFFER_SIZE];
- int read = 0;
- do{
- read = in.read(buffer);
- output.write(buffer, 0, read);
- } while(read>0);
- in.close();
- player = new MediaPlayer();
- player.setDataSource(f.getAbsolutePath());
- player.prepare();
- player.start();
Parsed in 0.032 seconds, using GeSHi 1.0.8.4
It works quite well.
But I'm searching a way to directly play the read data, without saving it.
As this is not PCM it doesn't work with AudioTrack.
Anybody an idea?
thanks for reading and hopefully helping



