HLS (http live streaming) on Android 3.0 and seeking

穿精又带淫゛_ 提交于 2019-12-29 03:52:05

问题


We have a provider that gives us m3u8 files for HLS streams (originally intended for use in an iOS app).

Android 3.0+ supports http live streaming (http://developer.android.com/guide/appendix/media-formats.html) - and we can in fact play these m3u8 files using the standard VideoView on Android 3.0+.

EDIT: Android seems to treat this as "real-time" video feed, and disables the ability to seek or calculate a video duration. (Where-as iOS let's you seek within the stream without issue)

Is there any way to force android 3.0+ to seek within these files?

Here is a sample activity for others to test with:

import android.app.Activity;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.VideoView;

public class SandboxActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        VideoView vw = (VideoView) findViewById(R.id.videoView);
      vw.setVideoPath("http://devimages.apple.com/iphone/samples/bipbop/gear4/prog_index.m3u8"); 
        vw.setMediaController(new MediaController(this));
        vw.requestFocus();
        vw.start();
    }
}

and a sample layout:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center" android:id="@+id/root">

    <VideoView
        android:id="@+id/videoView"
        android:layout_width="wrap_content"
        android:layout_height="match_parent" />
</RelativeLayout>

This is using a sample HLS link from Apple.


回答1:


Look at this (which you referred too) page

It says:

  • Protocol version 3 (Android 4.0 and above)
  • Protocol version 2 (Android 3.x)

And here you can check draft's for HLS. You can choose a version at the top of the page.

First reference to seeking appeared in draft 3 (comparing to draft 2 Android 3.x)

The value of the date and time provides an informative mapping of the timeline of the media to an appropriate wall-clock time, which may be used as a basis for seeking

Just to make sure. I didn't read through whole draft. But, my guess would be that Android implemented quite early draft in Android 3.0 and they may have implemented it partially, which is enough to play, but it's not enough to seek.

I don't think that you have an easy fix for this, except brining in 3rd party HLS client (as suggested by vipw)




回答2:


Sorry guys, you're trying to get blood from a stone. Android 3.0 supports a very limited subset of HLS, and to support seeking in live streams you're going to need a better HLS client than Google provides.




回答3:


Im not sure but since the VideoView is not supporting seeking for your case, you may try some different options like: http://wiki.videolan.org/AndroidCompile (which is easy to compile)




回答4:


Somewhat related to this - there seems to be a bug that prevents live HLS feeds from starting at the live point as they're supposed to. I imagine this may be due to this seeking limitation. When you start a live HLS feed (that does NOT have the EXT-X-ENDLIST tag) on Android, there is a bug in the core HLS parsing components that fails to start at the live point (end of the feed), and instead starts at the beginning of the stream.

There is a bug filed on code.google.com about this - you can 'star' or upvote it there:

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




回答5:


My guess is the seeking behavior you described was implemented using an iframe only playlist (#EXT-X-I-FRAMES-ONLY), which requires a client that supports at least version 4 of the Pantos spec.



来源:https://stackoverflow.com/questions/11019564/hls-http-live-streaming-on-android-3-0-and-seeking

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!