You could try it with a http connection. First store the incoming data
to the sdcard.

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();


Then you can play this with your MediaPlayer.

player = new MediaPlayer();
player.setDataSource(f.getAbsolutePath());
player.prepare();
player.start();


I don't know if that is exactly what you're looking for, but I hope it
can help you a bit.

Dose anyone know a solution for playing it without storing? Just
transferring the buffer to the player. It doesn't work with AudioTrack
(as this is not PCM).


On Sep 2, 11:32 am, siliconeagle <[email protected]> wrote:
> Also the URl is a http (MP3) stream URL - as opposed tioo other opost
> where RTSP is being tried. It looks like it should just work. Has
> anyone else got streaming working via a streaming URL?
>
> On Sep 1, 1:24 pm, siliconeagle <[email protected]> wrote:
>
> > I am trying to build streaming radio into my app, which works fines
> > streaming files over the internet, but when i try to use a shoutcast
> > url in get the error below, which from the soruce code looks liek the
> > mediaPlayer is looking for the duration in the header. Does anyone
> > know if shoutcast urls will work withthe default media player? Or do i
> > have to download chunks into a ping-pong buffer sor something? The url
> > has no porblems downloading via the browser.
>
> > the error is:-
>
> > 09-01 11:53:25.634 E/MediaPlayer(16972): stop called in state 1
> > 09-01 11:53:27.324 D/BatteryWidget(15623): Updating Views
> > 09-01 11:53:30.445 E/PlayerDriver(   35): Command PLAYER_INIT
> > completed with an error or infoPVMFFailure
> > 09-01 11:53:30.445 E/MediaPlayer(16972): error (1, -1)
> > 09-01 11:53:30.504 I/NotificationService(   55): enqueueToast
> > pkg=net.robmunro.mypod callback=android.app.ITransientNotification$Stub
> > $pr...@4323b8f8 duration=1000
> > 09-01 11:53:30.514 W/System.err(16972): java.io.IOException: Prepare
> > failed.: status=0x1
> > 09-01 11:53:30.644 W/System.err(16972): at
> > android.media.MediaPlayer.prepare(Native Method)
> > 09-01 11:53:30.644 W/System.err(16972): at
> > net.robmunro.mypod.util.MediaPlayerWrapper.playMedia
> > (MediaPlayerWrapper.java:111)
>
> > the code i use is:-
> > try {
> >         mPlayer.stop();
> >         mPlayer.reset();} catch (Exception e) {
>
> >         e.printStackTrace();}
>
> > this.source=source;
> > if (source.equals(Globals.SOURCE_LOCAL)) {
> >          mPlayer.setDataSource(f.path);
> >          buffered = 0;} else if (source.equals(Globals.SOURCE_STREAM)) {
>
> >         mPlayer.setDataSource(f.remoteUrl);
> >          buffered = 100;}
>
> > mPlayer.prepare();
> > mPlayer.start();

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to