Sunday, June 2, 2013

Android Http Live Streaming(HLS)

Http Live streaming(HLS) allows applications to stream the media content of servers. If you would like to follow HLS standards, the content type of the media should be in the format of m3u8. m3u8 file is a meta data container for the media information to play. As m3u8 is supported by Android 3.1 and above, if we provide m3u8 URL's the streaming will be automatically done by the Media Player or VideoView  object.

VideoView videoView = (VideoView) findViewById(R.id.videoView);
String httpLiveUrl = "http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8";
videoView.setVideoURI(Uri.parse(httpLiveUrl)); 
videoView.setMediaController(new MediaController(this));
videoView.requestFocus();
videoView.start();

Some of the working urls include

http://qthttp.apple.com.edgesuite.net/1010qwoeiuryfg/sl.m3u8
http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8

To support Android versions 2.1 and above use third party vitamo player.

12 comments:

  1. I am attempting to learn about streaming to android devices. It is immensely overwhelming at this point. As it stands I am able to stream to iOS devices fairly easily.

    If I were to utilize the code you have above, how do I implement it? Would it be added to a page as is and then the Android players will take over? As much as I know about streaming media, coding for Android has me at a loss.

    ReplyDelete
  2. I am integrate your code in my new android project . It's not play the video. It shows "Cant Play this video " in my android emulator .

    ReplyDelete
    Replies
    1. Can you please try it your real device?

      Delete
    2. It displays the same message "Can't play this video" in my real device?

      Delete
    3. This comment has been removed by the author.

      Delete
    4. Have you set the right internet accessing right in your manifest?

      like the below
      uses-permission android:name="android.permission.INTERNET"

      Delete
  3. Is there and option to change the segment for HLS using mediaplayer?
    I used 2 seconds and it didnt look well. Only the 10 second standard is good.

    ReplyDelete
  4. Hi Sree,
    some m3u8 videos are playing and some are not. Dont know why. do you have any answer?

    ReplyDelete
  5. was running between many players for HLS streaming now got it as simple. Thank you

    ReplyDelete