【问题标题】:Android - m3u8 video streamingAndroid - m3u8 视频流
【发布时间】:2018-06-15 11:17:40
【问题描述】:

我正在我的应用中流式传输实时视频。我有一个 .m3u8 链接,它在 vlc 播放器中完美运行。但是当我在我的应用程序中播放这个流时,视频的可视化被破坏了(见截图)。有谁知道,这是什么原因造成的?

编辑:我意识到这只发生在 Android 8.1 上。

【问题讨论】:

  • 你用哪个播放器在你的APP里串流
  • 你能把你的 m3u8 视频链接过去吗
  • 幸好是链接的问题。

标签: android stream vlc


【解决方案1】:

试试这个library for .m3u8,这会解决你的问题:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:app="http://schemas.android.com/apk/res-auto"
                android:layout_width="match_parent"
                android:layout_height="match_parent">

    <com.devbrackets.android.exomedia.ui.widget.VideoView
        android:id="@+id/video_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:useDefaultControls="true"/>

</RelativeLayout>

在Activity中写下代码

private VideoView videoView;

private void setupVideoView() {
    // Make sure to use the correct VideoView import
    videoView = (VideoView)findViewById(R.id.video_view);
    videoView.setOnPreparedListener(this);

    //For now we just picked an arbitrary item to play
    videoView.setVideoURI(Uri.parse("https://archive.org/download/Popeye_forPresident/Popeye_forPresident_512kb.m3u8"));
}

@Override
public void onPrepared() {
    //Starts the video playback as soon as it is ready
    videoView.start();
}

【讨论】:

    【解决方案2】:

    如果您使用 android studio 可以插入 NiceVieoPlayer 库,它功能强大并可以在所有设备上加载。 您可以使用它进行直播。

    它是一些中国人:D

    祝你好运。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-06
      • 1970-01-01
      • 2018-08-04
      • 1970-01-01
      • 2015-02-11
      相关资源
      最近更新 更多