Pasman
Pasman

Reputation: 445

Preload video on Android

I'm building an interactive movie of some sort , having more video clips that need to load between interactive scenes. The problem is there is a slight delay when starting the video which I believe it could be fixed by preloading the clip right before the previous one finishes. I've tried to start() the video and then stop() it, also seekTo() but i'm no getting the desired result.

Also I need to mention I'm using several VideoViews in the same Activity so I display the appropriate one.

The video files are loaded from the raw folder using the following code

    videoView1 = new VideoView(this);
    mediaController1= new MediaController(this);

    mediaController1.setMediaPlayer(videoView1);
    mediaController1.setVisibility(View.INVISIBLE);

    Uri uri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.sa1);
    videoView1.setMediaController(mediaController1);
    videoView1.setVideoURI(uri);

    videoView1.requestFocus();

    videoView1.start();

Thank you.

Upvotes: 0

Views: 3100

Answers (1)

Finnboy11
Finnboy11

Reputation: 986

You can handle the loading in another thread with using, for example, AsyncTask while the user watches the pervious video. http://developer.android.com/reference/android/os/AsyncTask.html

Upvotes: 1

Related Questions