Running sequence of videos in android with reduce in delay time
<p>I am running video in video view in android using threads. Following is my code can i reduce delay time between videos?? Their are three threads running one after another. On completion of thread three video thread one video starts but with a delay. Can this delay be reduced??</p>

<pre><code>//Code Statrs
package com.google.threaded;



import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.widget.MediaController;
import android.widget.VideoView;

public class threaded extends Activity {


private static int count=0;
private static final int STEP_ONE_COMPLETE = 0;
private static final int STEP_TWO_COMPLETE = 1;
private static final int STEP_Three_COMPLETE = 2;
private static final int STEP_Four_COMPLETE = 3;
private Thread Thread1,Thread2,Thread3,Thread4;
private final Object lock = new Object();
private String path="/data/abc.3gp";
MediaController  mc;
VideoView txtv1,txtv2,txtv3,txtv4;


  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);


        txtv1 = (VideoView) findViewById (R.id.txt1);
        txtv2 = (VideoView) findViewById(R.id.txt2);
        txtv3 = (VideoView) findViewById(R.id.txt3);
        mc = new MediaController(this);


        thread1();

   }


    //Thread Handler
private Handler threadHandler = new Handler() {
    @Override
    public void handleMessage(Message msg) {
        switch(msg.what){


        case STEP_ONE_COMPLETE:
            txtv1.setVideoPath(path);
            txtv1.setVisibility(VideoView.VISIBLE);
            txtv1.start();


            txtv1.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {

                @Override
                public void onCompletion(MediaPlayer mp) {
                    // TODO Auto-generated method stub
                    txtv1.setVisibility(VideoView.INVISIBLE);
                    txtv2.start();
                }
            });
            thread2();


            break;


        case STEP_TWO_COMPLETE:
            //count++;
            txtv2.setVideoPath(path);
            txtv2.setVisibility(VideoView.VISIBLE);
            txtv2.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
                @Override
                public void onCompletion(MediaPlayer mp) {
                    // TODO Auto-generated method stub


                    txtv2.setVisibility(VideoView.INVISIBLE);
                    txtv3.start();
                }
            });

            thread3();


            break;


        case STEP_Three_COMPLETE:
            count=1;
            txtv3.setVideoPath(path);
            txtv3.setVisibility(VideoView.VISIBLE);
            txtv3.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
                @Override
                public void onCompletion(MediaPlayer mp) {
                    // TODO Auto-generated method stub


                    txtv3.setVisibility(VideoView.INVISIBLE);
                    thread1();
                }
            });


            //thread4();
            break;


        }
    }

};

  //Thread 1    
  private void thread1(){
     Thread1 = new Thread(new Runnable() {
        @Override
        public void run() {
            // do first step


            // finished first step
            Message msg = Message.obtain();
            msg.what = STEP_ONE_COMPLETE;
            threadHandler.sendMessage(msg);
        }
    });
    Thread1.start();
}

 //Thread 2
 private void thread2(){
     Thread2 = new Thread(new Runnable()  {
        @Override
        public void run() {
            // do first step


            // finished first step
            Message msg = Message.obtain();
            msg.what = STEP_TWO_COMPLETE;
            threadHandler.sendMessage(msg);
        }
    });

        Thread2.start();
}

 //Thread 3
 private void thread3(){
     Thread3 = new Thread(new Runnable() {
        @Override
        public void run() {
            // do first step
            // finished first step
            Message msg = Message.obtain();
            msg.what = STEP_Three_COMPLETE;
            threadHandler.sendMessage(msg);

        }
    });

        Thread3.start();
}

}
//Code End
</code></pre>
