如何将Raspberry Pi相机源传输到Android VideoView

时间:2015-10-29 12:04:53

标签: android raspberry-pi video-streaming

在正确工作的片段中,我在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相机模块中输出视频输出。

上面的代码给出了错误“无法播放此视频”。 Screenshot from the running app

我的问题是如何解决这个问题。

0 个答案:

没有答案