1.create a folder called 'raw' in your folder 'res' and add your video to this folder
2.Just copy and paste the below code
public class ActivitySplash extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try { splashPlayer(); } catch (Exception ex) { jumpMain(); } } @Override public boolean onTouchEvent(MotionEvent ev) { return false; } public void splashPlayer() { VideoView videoHolder = new VideoView(this); setContentView(videoHolder); Uri video = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.splash); videoHolder.setVideoURI(video); videoHolder.setOnCompletionListener(new OnCompletionListener() { public void onCompletion(MediaPlayer mp) { jumpMain(); } }); videoHolder.start(); videoHolder.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { ((VideoView) v).stopPlayback(); jumpMain(); return true; } }); } private synchronized void jumpMain() { Intent intent = new Intent(ActivitySplash.this, ActivityMain.class); startActivity(intent); finish(); } }
No comments:
Post a Comment