同时显示4个视频

时间:2015-01-11 17:11:27

标签: android android-videoview

我遇到了VideoView的问题。我想同时播放4个视频。而且只有其中一人工作。(手枪)另一个没有出现。 我将此代码用于视频:

@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.****_layout, container, false);

        MediaController mediaController = new MediaController(getActivity());

        VideoView videopistol = (VideoView) view.findViewById(R.id.video_ability_pistol);
        Uri pistol = Uri.parse("android.resource://com.****.****/raw/video_ability_pistol");
        videopistol.setVideoURI(pistol);
        videopistol.setMediaController(mediaController);
        mediaController.setAnchorView(videopistol);
        mediaController.setMediaPlayer(videopistol);

        VideoView videoblink = (VideoView) view.findViewById(R.id.video_ability_blink);
        Uri blink = Uri.parse("android.resource://com.****.****/raw/video_ability_blink");
        videoblink.setVideoURI(blink);
        videoblink.setMediaController(mediaController);
        mediaController.setAnchorView(videoblink);
        mediaController.setMediaPlayer(videoblink);


        VideoView videorecall = (VideoView) view.findViewById(R.id.video_ability_recall);
        Uri recall = Uri.parse("android.resource://com.****.****/raw/video_ability_recall");
        videorecall.setVideoURI(recall);
        videorecall.setMediaController(mediaController);
        mediaController.setAnchorView(videorecall);
        mediaController.setMediaPlayer(videorecall);


        VideoView videopulse = (VideoView) view.findViewById(R.id.video_ability_pulse_bomb);
        Uri pulse = Uri.parse("android.resource://com.****.****/raw/video_ability_pulse_bomb");
        videopulse.setVideoURI(pulse);
        videopulse.setMediaController(mediaController);
        mediaController.setAnchorView(videopulse);
        mediaController.setMediaPlayer(videopulse);

        videopistol.start();
        videoblink.start();
        videorecall.start();
        videopulse.start();

        return view;
    }

和XML文件

<VideoView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/video_ability_pistol"/>
<VideoView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/video_ability_blink"/>
<VideoView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/video_ability_recall"/>
<VideoView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/video_ability_pusle_bomb"/>
有人可以帮帮我吗?我找不到问题。

0 个答案:

没有答案