How to add Video in android splash screen ?

In this tutorial we will be adding VideoView in our android apps splash screen. Splash screen is shown when you app starts upon clicking of app icon. Splash screen is generally 2-4 sec long. We had earlier added tutorial in which a logo is shown in splash screen.

This screen is basically shown for your brand promotion by showing some brand related icon. Google uses this in many of its products like YouTube, Google Maps.

Implementation Details

In this tutorial we will be using VideoView to play video in our activity. The VideoView class can load images from various sources (such as resources or content providers), takes care of computing its measurement from the video so that it can be used in any layout manager, and provides various display options such as scaling and tinting.

So here we will be creating 2 activities. One is Splash activity which is shown until video is being played. Other is MainActivity which is shown when Splash activity is completed.

Following is code for SplashActivity.java

Here we have taken a video file in raw folder in resources. We can reference raw folder content using R.raw.file_name . Now we have parsed a uri using raw resource reference and video url on VideoView.

Also added onComplete() listener so that we get call when video is complete. In this call we are finishing SplashActivity and starting MainActivity.

This is all we need to for adding Video in Splash Screen. Please comment for more clarification.

guru

Technology enthusiast. Loves to tinker with things. Always trying to create something wonderful using technology. Loves coding for Android, Raspberry pi, Arduino , Opencv and much more.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *