在正确工作的片段中,我在video_feed_fragment_layout.xml
中放了一个VideoView:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<VideoView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/videoView"
android:clickable="true"
android:foregroundGravity="center_vertical|center_horizontal" />
</LinearLayout>
使用VideoFeedFragment
中的相应类代码(省略导入):
public class VideoFeedFragment extends Fragment {
// Variable declaration
private VideoView videoView;
private Uri videoStream;
// Mandatory empty constructor
public VideoFeedFragment() {}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View root = inflater.inflate(R.layout.video_feed_fragment_layout, container, false);
videoView = (VideoView) root.findViewById(R.id.videoView);
videoStream = Uri.parse("http://pi5.akoo.nl:9000");
videoView.setVideoURI(videoStream);
videoView.requestFocus();
videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
videoView.start();
}
});
return root;
}
}
在 http://pi5.akoo.nl:9000 VLC上 - 在Raspberry Pi上运行 - 正在运行并从连接在其上的Raspberry Pi相机模块中输出视频输出。
我的问题是如何解决这个问题。