18

Android での HLS のサポート レベルに関して、いくつかの問題があることを認識しています。小さなビデオプレーヤーのデモを作成しようとしています (できるだけ多くのデバイスで動作するように)。できればサードパーティのライブラリを使用しないでください。HLS ビデオをストリーミングできます。

:現在JellyBean 4.2.2でテストしていますが、他のバージョンにアクセスできます

アプリがストリームの再生を開始できるように MediaPlayer クラスを使用することができました (たとえば、Apple のテスト ビデオBipBopAll ) が、ストリームの間違ったセクションを読み込んでいるようです。 (したがって、約30秒後に終了します)。

私が使用したコードは非常に基本的なものです。

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();
}

更新: ICS 4.0.4 で同じコードをテストしたところ、正しく動作しました。3.0.1 でテストすると、15 分でストリームが読み込まれ、そこから正しく実行されます。

ストリームが最初から開始され、複数の Android バージョンで正しく再生されるようにするにはどうすればよいですか?

または、使用すべきより良い実装はありますか?

4

4 に答える 4

1

Player に URL の開始パラメーターを指定しようとしましたか?

このような:

" http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8?start=0 "

于 2013-05-29T10:20:05.023 に答える
-1
   <?xml version="1.0" encoding="utf-8" ?> 
    - <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent">
      <VideoView android:id="@+id/surface_view" android:layout_width="fill_parent" android:layout_height="300dp" android:layout_gravity="center" /> 
      <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_below="@+id/surface_view" android:layout_marginRight="62dp" android:layout_marginTop="16dp" android:text="Stop" /> 
      <Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBaseline="@+id/button1" android:layout_alignBottom="@+id/button1" android:layout_alignParentLeft="true" android:layout_marginLeft="34dp" android:text="Start" /> 
      </RelativeLayout>

*******************************************************************
     startB.setOnClickListener(new View.OnClickListener() {
@Override
            public void onClick(View v) {
                 mVideoView = (VideoView) findViewById(R.id.surface_view);
                   mVideoView.setVideoURI(Uri.parse("http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"));                
                   mVideoView.setMediaController(new     MediaController(MainActivity.this));
                   mVideoView.requestFocus();              
                   mVideoView.postInvalidateDelayed(100);  
                  new Thread(new Runnable() {
                      public void run() {
                          mVideoView.start();

                      }
                  }).start();
            }
        });
于 2013-06-05T13:49:44.897 に答える