Splash screen video

MainActivity.java

public class MainActivity extends AppCompatActivity {

private VideoView mVideoView;

private ImageView ivImageView;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

mVideoView = (VideoView) findViewById(R.id.myvideoview);

ivImageView =(ImageView)findViewById(R.id.bg_iv);

mVideoView.setVideoURI((Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.payrgifcompressed)));

mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {

@Override

public void onPrepared(final MediaPlayer mediaPlayer) {

mVideoView.start();

runOnUiThread(new Runnable() {

@Override

public void run() {

while (mediaPlayer.isPlaying()) {

Log.d("MainActivity", "position "+mediaPlayer.getCurrentPosition());

if (mediaPlayer.getCurrentPosition() == 0) {

ivImageView.setVisibility(View.VISIBLE);

}else {

ivImageView.setVisibility(View.GONE);

break;

}

}

}

});

}

});

}

}

activitymain.xml

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout android:layout_height="match_parent"

android:layout_width="match_parent"

xmlns:android="http://schemas.android.com/apk/res/android">

<VideoView

android:id="@+id/myvideoview"

android:layout_width="match_parent"

android:layout_height="match_parent"/>

<ImageView

android:id="@+id/bg_iv"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:src="@drawable/pyar_logo"

android:background="@android:color/white"/>

</RelativeLayout>

Source Code: https://github.com/lokeshkondaparthi/VideoDemo