我正在尝试让我的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;
}
答案 0 :(得分:1)
您无法更新doInBackground
方法的视图。移动代码以更新onPostExecute
方法上的视图。