Android loading animation before VideoView start

magiccyril picture magiccyril · May 2, 2011 · Viewed 16.9k times · Source

I don't find any solution to show a loading animation (or just an imageView) before a VideoView start to play : during the video is buffering.

Does anyone have a clue ?

Thanks.

Answer

Mehmet Emre picture Mehmet Emre · Apr 25, 2012

Or you can just use Progress Dialog;

public class VideoEkrani extends Activity {

    VideoView ekran;
    String kaynakYolu = "http://commonsware.com/misc/test2.3gp";
    ProgressDialog progDailog;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.sayfa_video_goruntule);


        ekran = (VideoView) findViewById(R.id.videoViewESPU);
        ekran.setMediaController(new MediaController(this));
        ekran.setVideoURI(Uri.parse(kaynakYolu));
        ekran.requestFocus();
        ekran.start();

        progDailog = ProgressDialog.show(this, "Please wait ...", "Retrieving data ...", true);

        ekran.setOnPreparedListener(new OnPreparedListener() {

            public void onPrepared(MediaPlayer mp) {
                // TODO Auto-generated method stub
                progDailog.dismiss();
            }
        });
    }
}