I've been trying to stream .asx file and it was not working and mediaplayer returns errors.
This is my code
MediaPlayer mp = new MediaPlayer();
MediaPlayer mp = new MediaPlayer();
try {
Uri uri = Uri.parse("http://www.tamilatlas.com/tamilrmxs/dynasty/dynastychunez.asx");
mp.setDataSource(uri.toString());
mp.prepare();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
mp.start();
I found following error in logcat
11-01 10:03:59.484: E/MediaPlayer(21233): error (1, -2147483648)
11-01 10:03:59.484: W/System.err(21233): java.io.IOException: Prepare failed.: status=0x1
11-01 10:03:59.488: W/System.err(21233): at android.media.MediaPlayer.prepare(Native Method)
11-01 10:03:59.488: W/System.err(21233): at com.mayuonline.streaming.StreamingActivity.onCreate(StreamingActivity.java:18)
11-01 10:03:59.488: W/System.err(21233): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-01 10:03:59.488: W/System.err(21233): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
11-01 10:03:59.488: W/System.err(21233): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
11-01 10:03:59.488: W/System.err(21233): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
11-01 10:03:59.488: W/System.err(21233): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
11-01 10:03:59.492: W/System.err(21233): at android.os.Handler.dispatchMessage(Handler.java:99)
11-01 10:03:59.492: W/System.err(21233): at android.os.Looper.loop(Looper.java:123)
11-01 10:03:59.496: W/System.err(21233): at android.app.ActivityThread.main(ActivityThread.java:3683)
11-01 10:03:59.496: W/System.err(21233): at java.lang.reflect.Method.invokeNative(Native Method)
11-01 10:03:59.499: W/System.err(21233): at java.lang.reflect.Method.invoke(Method.java:507)
11-01 10:03:59.499: W/System.err(21233): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-01 10:03:59.499: W/System.err(21233): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-01 10:03:59.499: W/System.err(21233): at dalvik.system.NativeStart.main(Native Method)
11-01 10:03:59.503: E/MediaPlayer(21233): start called in state 0
11-01 10:03:59.507: E/MediaPlayer(21233): error (-38, 0)
11-01 10:03:59.511: E/MediaPlayer(21233): Error (-38,0)
Thanks for your time. I've been searching in many place but there are no valid example for asx streaming.
You will have to parse the .asx file, to find the links(s) to the real stream there.
Here's a link for the .asx file format, maybe that can give you some hints as to how you will parse it: http://en.wikipedia.org/wiki/Advanced_Stream_Redirector
I can tell you that I succeded in parsing one .asx file with the
Scanner
class. I did not find any general solution though. But maybe this is enough to get you started.