How to play m3u8 on Android?

Saasha picture Saasha · Jun 1, 2011 · Viewed 60.5k times · Source

As i understood, Android 3.0 and above are able for play radio streaming m3u8 - http://developer.android.com/guide/appendix/media-formats.html

I put this link - http://content.mobile-tv.sky.com/content/ssna/live/ssnraudio.m3u8 into MediaPlayer but in LogCat i get:

06-01 09:04:44.287: INFO/LiveSession(33): onConnect 'http://content.mobile-tv.sky.com/content/ssna/live/ssnraudio.m3u8'
06-01 09:04:44.287: INFO/NuHTTPDataSource(33): connect to content.mobile-tv.sky.com:80/content/ssna/live/ssnraudio.m3u8 @0
06-01 09:04:44.747: INFO/NuHTTPDataSource(33): connect to content.mobile-tv.sky.com:80/content/ssna/live/ssnraudio.m3u8 @0
06-01 09:04:45.019: INFO/NuHTTPDataSource(33): connect to content.mobile-tv.sky.com:80/content/ssna/live/ssnraudio/ssnr_052311_071632_78731.aac @0
**06-01 09:04:45.817: ERROR/LiveSession(33): This doesn't look like a transport stream...**
06-01 09:04:45.967: INFO/HTTPLiveSource(33): input data EOS reached.

This is my source code:

    mp = new MediaPlayer();        
    start.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub              
            try {

                mp.setDataSource("http://content.mobile-tv.sky.com/content/ssna/live/ssnraudio.m3u8");
                mp.prepare();
                mp.start();

            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } 
        }
    });

    stop.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            try {

                mp.stop(); 
                mp.reset();

            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } 
        }
    });
}

Answer

Maks picture Maks · Aug 25, 2011

Following this link trail: http://code.google.com/p/android/issues/detail?id=14646

->

http://code.google.com/p/android/issues/detail?id=16884

->

http://code.google.com/p/android/issues/detail?id=17118

(ARGGGGH!)

Gives the answer in the end:

basically in Android v2.3 & v3.0, use the non-standard httplive:// scheme, in 3.1 use http:// but with some code workaround in how you call the relevant methods in the media framework.