0

我正在尝试使我的 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;

        }
4

1 回答 1

1

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

于 2013-03-25T06:37:15.717 回答