0

我正在开发一个应用程序,其中一个屏幕需要 4 个 videoviewa,视图就像一个屏幕上的四个方形框我在一个活动中拍摄了 4 个 videoview 这里是代码

vid1 = (VideoView) mView.findViewById(R.id.vid1);
        vid2 = (VideoView) mView.findViewById(R.id.vid2);
        vid3 = (VideoView) mView.findViewById(R.id.vid3);
        vid4 = (VideoView) mView.findViewById(R.id.vid4);

private void PlayVideo() {
        lnrVideoPlayback.setVisibility(View.VISIBLE);
        Thread t1 = null, t2 = null, t3 = null, t4 = null;
        if (prefsVideo.getString("v1URI", null) != null) {

            vid1.setVideoURI(Uri.parse(prefsVideo.getString("v1URI", null)));
//          vid1.setLayoutParams(new LinearLayout.LayoutParams(getResources()
//                  .getDimensionPixelSize(R.dimen.boxviewheight),
//                  getResources().getDimensionPixelSize(R.dimen.boxviewheight)));

            vid1.setVisibility(View.VISIBLE);
            t1 = new Thread(new Runnable() {

                @Override
                public void run() {
                    android.os.Process
                            .setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_DISPLAY);

                    vid1.start();

                }
            });
        }
        if (prefsVideo.getString("v2URI", null) != null) {
            vid2.setVideoURI(Uri.parse(prefsVideo.getString("v2URI", null)));
            vid2.setMediaController(new MediaController(getActivity()));
            vid2.setVisibility(View.VISIBLE);
            t2 = new Thread(new Runnable() {

                @Override
                public void run() {
                    android.os.Process
                            .setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_DISPLAY);
                    vid2.start();
                }
            });
        }
        if (prefsVideo.getString("v3URI", null) != null) {
            vid3.setVideoURI(Uri.parse(prefsVideo.getString("v3URI", null)));
            vid3.setMediaController(new MediaController(getActivity()));
            vid3.setVisibility(View.VISIBLE);
            t3 = new Thread(new Runnable() {

                @Override
                public void run() {
                    android.os.Process
                            .setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_DISPLAY);
                    vid3.start();
                }
            });
        }
        if (prefsVideo.getString("v4URI", null) != null) {
            vid4.setVideoURI(Uri.parse(prefsVideo.getString("v4URI", null)));
            vid4.setMediaController(new MediaController(getActivity()));
            vid4.setVisibility(View.VISIBLE);
            t4 = new Thread(new Runnable() {

                @Override
                public void run() {
                    android.os.Process
                            .setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_DISPLAY);

                    vid4.start();
                }
            });
        }

        t1.start();
        t2.start();
        t3.start();
        t4.start();

    }

当我播放单个视频而不是正确播放时,当我一起播放 4 个视频时,它会在所有 4 个视频中显示消息“视频无法播放”

4

1 回答 1

1

这取决于您设备的系统/框架实现。

  1. 允许同时使用的最大媒体播放器实例数
  2. 允许同时使用的最大视频表面数

通常,数字是 2。

于 2013-11-08T15:48:29.403 回答