VideoView(无法在线程内创建处理程序)

时间:2013-03-25 06:35:19

标签: android android-videoview

我正在尝试让我的VideoView与Asynctask一起使用。但是,我无法理解一些错误。有谁可以检查我的代码?我收到此错误“java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()

@Override
        protected Void doInBackground(Void... params) {
            try {
                getWindow().setFormat(PixelFormat.TRANSLUCENT);
                MediaController mediaController = new MediaController(
                        MainActivity.this);
                mediaController.setAnchorView(videoView);

                Uri video = Uri.parse(videoPath);
                videoView.setMediaController(mediaController);
                videoView.setVideoURI(video);
                videoView.requestFocus();
                videoView.setOnPreparedListener(new OnPreparedListener() {

                    public void onPrepared(MediaPlayer mp) {

                        pDialog.dismiss();
                        videoView.start();
                    }
                });
            } catch (Exception e) {

                System.out.println("Video Play Error :" + e.toString());
                // finish();
            }
            return null;

        }

1 个答案:

答案 0 :(得分:1)

您无法更新doInBackground方法的视图。移动代码以更新onPostExecute方法上的视图。