I realise that there are some issues in terms of level of support of HLS in Android. I'm trying to write a small videoplayer demo (to work on as many devices as possible); preferably without using a third party library; that can stream HLS video.
NOTE: I'm currently testing on JellyBean 4.2.2, but have access to other versions
I have managed to use the MediaPlayer class so that my app is able to start playing a stream (eg Apple's test video BipBopAll), but it seems to be loading the wrong section of the stream, as the video seems to start at 29 minutes in (and so it finishes after about thirty seconds).
The code that I've used is pretty basic:
private void playTrack()
{
player = new MediaPlayer();
try
{
player.setDisplay(holder);
player.setDataSource("http://devimages.apple.com/iphone/samples/bipbop
/bipbopall.m3u8");
player.prepare();
}
catch (...)
{
}
player.start();
}
Update: I've tested the same code on ICS 4.0.4, and it works correctly. Testing in 3.0.1, loads the stream at 15 minutes, and then runs correctly from there.
What can I do to ensure that the stream starts at the beginning, and plays correctly on multiple Android versions?
Or, is there a better implementation that I should use?
It is the default media streaming protocol for all iOS devices, but it can be used on Android and web browsers. The basic building blocks of a HLS streams are: M3U8 playlists. Media files for various streams.
Because UDP is faster, some streaming protocols use UDP instead of TCP. HLS, however, uses TCP. This is for several reasons: HLS is over HTTP, and the HTTP protocol is built for use with TCP (with some exceptions).
HLS is highly scalable for delivering live streams and video content across global content delivery networks (CDNs) using ordinary web servers.
HTTP Live Streaming (also known as HLS) is an HTTP-based adaptive bitrate streaming communications protocol developed by Apple Inc. and released in 2009. Support for the protocol is widespread in media players, web browsers, mobile devices, and streaming media servers.
Following some further investigation, I've found the following information that can hopefully help other people get HLS streaming on Android working.
Encoding - The video encoding, and the segmentation setup can have a large impact on the Android versions that the video supports. I ended up creating a video using HandBrake, with the following settings:
Segmentation - Using the Apple MediaFileSegmenter, I found adding the "-no-floating-point-duration" and "-z none" flags allowed me to create a video that worked across Android 3.0->4.2
Gingerbread - I was unable to get Android 2.3 to work with HLS out of the box, but I did find that using the Vitamio library worked pretty well (see this question for further info)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With