Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Audio Live stream: maximizing user base(decoding issue)

Tags:

android

I'd like to build an application that will be based on live stream(radio). Here're some links I can start with: 1) mp3, 2) aac("http://79.143.70.114:8000/detifm-64k.aac").

Unfortunately, those links couldn't be played by MediaPlayer on devices with Android 2.x. I'm a bit confused about this situation since this piece of documentation states that HTTP/HTTPS live streaming draft protocol is only partially supported by the Android 2.x systems - for instance,my device(Samsung I9001) is not able to play links from above but able to play this one which is also an mp3 live stream as stated here. On other devices like Samsung GTS 5830 even the latest link can't played.

My goal is to maximize user base as much as possible - what can I do to achieve it ?

Firstly, I'm not really familiar with encoding/decoding technologies but, I guess, there're different ways to encode the same mp3, since mp3 can't be played while "http://188.138.112.71:9018/"(City Beat Radio) can. So I need to know which types of encoding are more suited for Android and find out which one will be supported by the most of devices. This states "Mono/Stereo 8-320Kbps constant (CBR) or variable bit-rate (VBR)" - is this all I need to know ? What about playing live streams on Samsung GTS 5830 ?

Secondly, decoding is dependent upon hardware. I've seen a library called Vitamio that solves the issue of playing the first link, but I don't like the idea that user has to download additional third party software. Additionally, there's a MoboPlayer that also can play the first link. This is because they use software decoding - I wonder if there's any software decoding library I can incorporate into my project. I guess writing my own decoder would be tedious but your suggestions are welcome.

Thirdly, I've heard there's a way of live streaming through RTSP protocol, which is better supported by Android but I'm not familiar with this practice and haven't found any examples of mp3 live streams that I can check. Do you think it's worth trying ? And could you give an example of live rstp mp3 stream ?

Here's simple code that I used to test. The first link(mp3) resulted in java.io.IOException: Prepare failed.: status=0xFFFFFFF6 and the second([aac][2]) - java.io.IOException: Prepare failed.: status=0x1

mMediaPlayer = new MediaPlayer();
    try {
        mMediaPlayer
            .setDataSource(
                this,
                Uri.parse("http://radio02-cn03.akadostream.ru:8114/detifm192.mp3"));
        mMediaPlayer.setOnPreparedListener(mOnPreparedListener);
        mMediaPlayer.setOnErrorListener(mOnErrorListener);
        //mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
        mMediaPlayer.prepare();
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (SecurityException e) {
        e.printStackTrace();
    } catch (IllegalStateException e) {
        e.printStackTrace();
    } catch (NotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

private OnPreparedListener mOnPreparedListener = new OnPreparedListener() {

    @Override
    public void onPrepared(MediaPlayer mplayer) {
        mplayer.start();
    }
};

UPD

LOGCAT for the first link(mp3) on Samsung I9001:

08-28 13:38:45.522: E/MediaPlayer(31713): message received msg=3, ext1=0, ext2=0 08-28 13:38:45.542: E/MediaPlayer(31713): message received msg=200, ext1=1, ext2=26 08-28 13:38:45.542: W/MediaPlayer(31713): info/warning (1, 26) 08-28 13:38:45.552: E/MediaPlayer(31713): message received msg=100, ext1=-10, ext2=-10 08-28 13:38:45.552: E/MediaPlayer(31713): error (-10, -10) 08-28 13:38:45.562: W/System.err(31713): java.io.IOException: Prepare failed.: status=0xFFFFFFF6 08-28 13:38:45.562: W/System.err(31713): at android.media.MediaPlayer.prepare(Native Method) 08-28 13:38:45.562: W/System.err(31713): at com.example.sampleradioapp.MainActivity.onCreate(MainActivity.java:53) 08-28 13:38:45.562: W/System.err(31713): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 08-28 13:38:45.562: W/System.err(31713): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615) 08-28 13:38:45.562: W/System.err(31713): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667) 08-28 13:38:45.562: W/System.err(31713): at android.app.ActivityThread.access$1500(ActivityThread.java:117) 08-28 13:38:45.562: W/System.err(31713): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) 08-28 13:38:45.562: W/System.err(31713): at android.os.Handler.dispatchMessage(Handler.java:99) 08-28 13:38:45.562: W/System.err(31713): at android.os.Looper.loop(Looper.java:130) 08-28 13:38:45.562: W/System.err(31713): at android.app.ActivityThread.main(ActivityThread.java:3687) 08-28 13:38:45.562: W/System.err(31713): at java.lang.reflect.Method.invokeNative(Native Method) 08-28 13:38:45.562: W/System.err(31713): at java.lang.reflect.Method.invoke(Method.java:507) 08-28 13:38:45.592: W/System.err(31713): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867) 08-28 13:38:45.592: W/System.err(31713): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625) 08-28 13:38:45.592: W/System.err(31713): at dalvik.system.NativeStart.main(Native Method) 08-28 13:38:45.622: I/MediaPlayer(31713): Info (1,26)

LOGCAT for the first link(mp3) on Samsung GTS 5830:

08-28 13:15:54.119: I/MediaPlayer(24178): uri is:http://radio02-cn03.akadostream.ru:8114/detifm192.mp3 08-28 13:15:54.119: I/MediaPlayer(24178): path is null 08-28 13:15:54.119: D/MediaPlayer(24178): Couldn't open file on client side, trying server side 08-28 13:16:05.139: E/MediaPlayer(24178): error (1, -2147483648) 08-28 13:16:05.249: E/MediaPlayer(24178): Error (1,-2147483648)

LOGCAT for the second link(aac) on Samsung I9001:

08-28 13:40:46.681: E/MediaPlayer(31748): message received msg=100, ext1=1, ext2=-2147483648 08-28 13:40:46.681: E/MediaPlayer(31748): error (1, -2147483648) 08-28 13:40:46.681: W/System.err(31748): java.io.IOException: Prepare failed.: status=0x1 08-28 13:40:46.681: W/System.err(31748): at android.media.MediaPlayer.prepare(Native Method) 08-28 13:40:46.681: W/System.err(31748): at com.example.sampleradioapp.MainActivity.onCreate(MainActivity.java:53) 08-28 13:40:46.691: W/System.err(31748): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 08-28 13:40:46.691: W/System.err(31748): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615) 08-28 13:40:46.691: W/System.err(31748): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667) 08-28 13:40:46.691: W/System.err(31748): at android.app.ActivityThread.access$1500(ActivityThread.java:117) 08-28 13:40:46.691: W/System.err(31748): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) 08-28 13:40:46.691: W/System.err(31748): at android.os.Handler.dispatchMessage(Handler.java:99) 08-28 13:40:46.701: W/System.err(31748): at android.os.Looper.loop(Looper.java:130) 08-28 13:40:46.701: W/System.err(31748): at android.app.ActivityThread.main(ActivityThread.java:3687) 08-28 13:40:46.701: W/System.err(31748): at java.lang.reflect.Method.invokeNative(Native Method) 08-28 13:40:46.701: W/System.err(31748): at java.lang.reflect.Method.invoke(Method.java:507) 08-28 13:40:46.701: W/System.err(31748): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867) 08-28 13:40:46.701: W/System.err(31748): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625) 08-28 13:40:46.701: W/System.err(31748): at dalvik.system.NativeStart.main(Native Method)

LOGCAT for the second link(aac) on Samsung GTS 5830:

08-28 13:19:03.929: I/MediaPlayer(24352): path is null 08-28 13:19:03.929: D/MediaPlayer(24352): Couldn't open file on client side, trying server side 08-28 13:19:29.119: E/MediaPlayer(24352): error (1, -2147483648) 08-28 13:19:29.119: W/System.err(24352): java.io.IOException: Prepare failed.: status=0x1 08-28 13:19:29.119: W/System.err(24352): at android.media.MediaPlayer.prepare(Native Method) 08-28 13:19:29.119: W/System.err(24352): at com.example.sampleradioapp.MainActivity.onCreate(MainActivity.java:53) 08-28 13:19:29.119: W/System.err(24352): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 08-28 13:19:29.119: W/System.err(24352): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615) 08-28 13:19:29.119: W/System.err(24352): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667) 08-28 13:19:29.119: W/System.err(24352): at android.app.ActivityThread.access$1500(ActivityThread.java:117) 08-28 13:19:29.119: W/System.err(24352): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) 08-28 13:19:29.119: W/System.err(24352): at android.os.Handler.dispatchMessage(Handler.java:99) 08-28 13:19:29.119: W/System.err(24352): at android.os.Looper.loop(Looper.java:130) 08-28 13:19:29.119: W/System.err(24352): at android.app.ActivityThread.main(ActivityThread.java:3687) 08-28 13:19:29.119: W/System.err(24352): at java.lang.reflect.Method.invokeNative(Native Method) 08-28 13:19:29.119: W/System.err(24352): at java.lang.reflect.Method.invoke(Method.java:507) 08-28 13:19:29.129: W/System.err(24352): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867) 08-28 13:19:29.129: W/System.err(24352): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625) 08-28 13:19:29.129: W/System.err(24352): at dalvik.system.NativeStart.main(Native Method)

Thanks for your suggestions.

like image 850
midnight Avatar asked Nov 12 '22 23:11

midnight


1 Answers

hi this may helps you

streaminlike

And Set MediaPlayer as
private void initializeMediaPlayer() {
        player = new MediaPlayer();
        try {
            player.setDataSource("http://usa8-vn.mixstream.net:8138");
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (IllegalStateException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
like image 186
Ankitkumar Makwana Avatar answered Dec 24 '22 22:12

Ankitkumar Makwana