Android - m3u8 视频流

标签 android stream vlc

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

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

最佳答案

试试这个 library对于 .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();
}

关于Android - m3u8 视频流,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50874505/

相关文章:

java - 如何将变量从 Main Activity 传递到 AsyncTask 及其方法?

c# - 使用 EndOfStream 属性后的 StreamReader.BaseStream 问题

android - 如何在c4droid中使用sd2原语和sdl2_gfx

android - Linux 下是 iwconfig,Android 下呢

delphi - 通过IdHTTP读取并保存部分文件流

video - 如何以编程方式检查 MP4 是否已损坏?

python - 使用 VLC 的 Python 绑定(bind)时,选项 --plugin-path 不再存在错误

android - 紧急求救 :Streaming video from android camera to VLC player on PC

java - 获取 java.lang.runtimeException

node.js - 如何将 STDOUT 从生成的子进程传输到日志文件中并同时将其打印到控制台?