Playing videos one by one issue : Android SDK
<p>I have an requirement in which I want to play the second video immediately once first video gets completed finishing. I have implemented this functionality, but the issue I am seeing is appearance of black screen between video transition.  I am trying this on Galaxy S device (1 GHZ processor, 512 MB RAM).</p>

<p>I have used VideoView, SurfaceView, but still issue is not resolved.  It looks like video preparation is taking time. I have used recommended videos format (H264 encoded videos with around 500 bit rate). Considering device Galaxy S  1 GHZ processor, this issue should not occur. </p>

<p>Any related pointer will be appreciated.</p>

<p>Thanks!
Nilesh</p>

<p>Here is the code:</p>

<p>Here is the code. I am having two videos : video1 and video2. After playing first, I am loading Video2.  Here I am using videoview</p>

<pre><code>package com.activity;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.net.Uri;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import android.widget.Toast;
import android.widget.VideoView;

public class FirstActivity extends Activity implements OnCompletionListener
{
    /** Called when the activity is first created. */
    VideoView video;
     Toast toast;
    boolean first;
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        overridePendingTransition(0, 0);
        setContentView(R.layout.main);
        video = (VideoView) findViewById(R.id.videoView1);
        Uri uri = Uri.parse("android.resource://" + getPackageName() + "/"
                + R.raw.video1);
        video.setOnCompletionListener(this);
        video.setVideoURI(uri);
        video.start();
        first=true;
    }

    public void onCompletion(MediaPlayer mp) {
        // TODO Auto-generated method stub
        if(first){
            Uri uri = Uri.parse("android.resource://" + getPackageName() + "/"
                    + R.raw.video1);
            video.setOnCompletionListener(this);
            video.setVideoURI(uri);
            video.start();
            first=false;
        }
        else{
            Uri uri = Uri.parse("android.resource://" + getPackageName() + "/"
                    + R.raw.video2);
            video.setOnCompletionListener(this);
            video.setVideoURI(uri);
            video.start();
            first=true;
        }
    }

    public boolean onTouchEvent(MotionEvent event) {
        // TODO Auto-generated method stub
        ImageView image = new ImageView(this);
        image.setBackgroundColor(Color.WHITE);
        image.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
                LayoutParams.FILL_PARENT));
        toast = new Toast(getApplicationContext());
        toast.setView(image);
        toast.setDuration(Toast.LENGTH_LONG);
        toast.show();
        Intent intent = new Intent(FirstActivity.this, SecondActivity.class);
        startActivity(intent);
        return true;
    }
}
</code></pre>
