Here's my activity code:
public class VideoActivity extends FragmentActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video);
VideoView videoView = (VideoView) findViewById(R.id.activity_video_videoview);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
Uri video = Uri
.parse("http://www.ebookfrenzy.com/android_book/movie.mp4");
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.start();
}
}
While video is buffering and not played I want to display progress bar. How can I do it?
Set an OnPreparedListener and dismiss the dialog there:
Declare the progress dialog in your activity:
private static ProgressDialog progressDialog;
Then in onCreate method:
...
progressDialog = ProgressDialog.show(this, "", "Loading...", true);
videoView.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer arg0) {
progressDialog.dismiss();
videoView.start();
}
});