我正在我的应用中播放实时视频。我有一个.m3u8链接,它在vlc播放器中运行得很好。但是当我在我的应用程序中播放此流时,视频的可视化已损坏(请参见屏幕截图)。有谁知道,这会导致什么?
编辑:我意识到这只发生在Android 8.1上。
答案 0 :(得分:3)
针对.m3u8试试这个library,这将解决您的问题:
<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();
}
答案 1 :(得分:0)