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