代码之家  ›  专栏  ›  技术社区  ›  Matej KoÅ¡út

android-m3u8视频流

  •  4
  • Matej KoÅ¡út  · 技术社区  · 6 年前

    我正在我的应用程序中播放实时视频。我有一个.m3u8链接,它在vlc播放器中工作得很好。但当我在我的应用程序中播放此流时,视频的可视化效果被破坏(见屏幕截图)。有人知道,是什么原因造成的吗? damaged video

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

    2 回复  |  直到 6 年前
        1
  •  3
  •   Ejaz Ahmad    6 年前

    试试这个 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>
    

    在活动中写下以下代码

    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
  •  0
  •   Hossin Asaadi    6 年前

    如果你使用android studio可以导入 NiceVieoPlayer 库,它充满电并加载到所有设备上。 你可以用它来生活。

    它是一些中国人:D

    古德拉克。