views:

229

answers:

1

I have an app that displays a video using VideoView. The layout consists of a Clock and a VideoView laid out in a simple vertical LinearLayout.

Here's my code snippet that I use:

VideoView mVideoView = new VideoView(this); mVideoView.setVideoPath(myVideoURL); mVideoView.requestFocus(); mVideoView.start();

Since the buffering of the video takes about 8-10 seconds, the layout comes up with the Clock, but the VideoView stays blank. What I want to achieve is this:

-- Display an ImageView for the 10s while the video is buffering -- Detect when the video is ready to be played (onPrepared?) -- Show the Clock and VideoView and start the Video

Anyone have pointers on how to go about this?

Thanks Chris

A: 

MediaPlayer will let you register an OnPreparedListener callback which you can use to determine when the video is ready to be started. So you would show your ImageView instead of your VideoView first, then when your callback gets called, change to the VideoView and start playing.

JRL
So make the ImageView visible, and then onPrepared, make the Imageview invisible and make the Clock and VideoView visible, and then call mVideoView.start()?
Chris
@Chris: sure...
JRL