Prepare Failed on Mediaplayer when trying to stream

1,632 views
Skip to first unread message

spurnd

unread,
Dec 4, 2011, 10:05:00 AM12/4/11
to android-platform
Hello

I am trying to stream an MP3-file using the following code:

player = new MediaPlayer();
String uri = "http://192.168.2.102:8080/sound/test.mp3";
player.setDataSource(uri);
player.prepare();

for some reason every time I call prepare I get the following
IOException: java.io.IOException: Prepare failed.: status=0x1
I tested the link directly in a browsr and it works.
I also added the Internet permission in the manifest.

Anyone know what I am doing wrong?

thanks for the help

priya.bala...@wipro.com

unread,
Dec 6, 2011, 12:48:50 AM12/6/11
to android-...@googlegroups.com
Hi,

Can you please call mediaplayer start after prepare is complete, by registering for setOnPreparedListener() event?

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MediaPlayer player = MediaPlayer.create(this, Uri.parse("http://192.168.2.102:8080/sound/test.mp3"));
player.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mp.start();
}
});
}

Thanks and Regards,
Priya
________________________________________
From: android-...@googlegroups.com [android-...@googlegroups.com] on behalf of spurnd [bernd.v...@gmail.com]
Sent: Sunday, December 04, 2011 8:35 PM
To: android-platform
Subject: Prepare Failed on Mediaplayer when trying to stream

Hello

thanks for the help

--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To post to this group, send email to android-...@googlegroups.com.
To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-platform?hl=en.

Reply all
Reply to author
Forward
0 new messages