以下是我在我的应用中使用的代码。我不知道它有什么不对,请任何人帮助我
VideoView videoView = (VideoView) dialoglayout.findViewById(R.id.videoView);
MediaController mediaController = new MediaController(getActivity(),false);
Uri video = Uri.parse(link);
videoView.setMediaController(mediaController);
mediaController.setMediaPlayer(videoView);
videoView.requestFocus();
videoView.setVideoURI(video);
videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener()
{
public void onPrepared(MediaPlayer mp)
{
hideProgressDialog();
videoView.start();
}
});
videoView.start();
答案 0 :(得分:0)
下面的代码对我有用,你可以试试这可以帮到你。
mediaControls = new MediaController(StackOverViewSample.this);
mViewVideo = (VideoView) findViewById(R.id.video_view);
try {
mViewVideo.setMediaController(mediaControls);
mViewVideo.setVideoURI(my_uri);
} catch (Exception e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
mViewVideo.requestFocus();
mViewVideo.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
mViewVideo.start();
}
});