How To Code a Video Player, Android Tutorial '
Prev Tutorial App Coding a Media Player for Audio

This Tutorial App Coding a Video Player

Next Tutorial App Adding Local Languages To Your App

Coding a Video Player

If you are just arriving at this page; and you are not familiar with with creating Android Apps, we suggest you begin with our tutorials: Coding Android App Pages and How To Create a Simple App in Android

From there follow along with each tutorial lesson.


We are using AIDE(a mobile coding environment using language java/xml), to create these tutorial apps on our
tablet(7" screen) that has android version 5.0.
Once we build and RUN our app; we then install the app on this same tablet; and the app is also installed on a smart phone that has android version 6.

We are using the AIDE coding editor to code our pages; and then to Create - RUN our apps. AIDE is a SDK coding environment for android devices like a tablet or smartphone. AIDE has a free and paid version. Once you create your apps code pages, you need to RUN the app to build your apk package; then you INSTALL it on your tablet or smartphone. For info on using AIDE, gohere

You can also create; RUN your apps using the code in these tutorials, with Android Studio. Android Studio is for desktop computers. Choose Java XML as the programming language. Android Studio is free to install and use for your android app development. Although not as convenient as testing your app on an actual android device; you can test your newly created app in Android Studio using its' android emulator.

Complete Example Codes are available for each of our tutorials. With these example codes you can make a functioning android app in either AIDE or Android Studio.


First, create a java/xml android template app using AIDE, (or Android Studio). Then you can get the code for this app from the EXAMPLE CODE section on this page. Replace the code on the pages you need to(with our tutorial code); in order to create this app.
Sometimes, new pages have to be created.
All the other coded pages in your app can remain as they are; they don't need to be changed.

This is the App - Video Player
It can play video files.
It loads and plays automatically when your app page loads.

App Photo Video Player

Where - How To Use Video View Code Class

For this video player we are using the VideoView code class. This code is defined in the layout file at main.xml, and then in our java class file at We define the location of our VideoView using the findViewById method, and by using the Media Controller method.

The location of the video file to be played is also declared in the java file. All media type files are put in the res/raw folder of your app project. You usually have to create the folder - raw.

For our video player; we are making a simple app that will play a video file when the view loads onto the screen. We did not code any buttons for this video player app; however, because we are using the VideoView class and MediaController method; Play and Pause toggle buttons will show in the view when you tap on the screen. They remain visible for a few seconds.

Additional Reading at Android Developer website
Media Controller For Video View Media Formats Android

Creating - Naming Your App Using AIDE

When creating your app,(from left menu) choose:
Create New Project;
Then, choose
New Android App(gradle, android Java/xml)
Hello World App Java/xml
if your using the original version of AIDE

You can name your app whatever you like; if your using the name as shown in our example code use;

VideoPlayer for the App Name and,
for the package name(next line) use:

If you want to name it differently, you can, just change the app name in the strings.xml file at app_name, and change it on the left menu in AIDE, just highlight app name, then select rename, type the new name.
You cannot change the app package name.

The Coded Pages

Code for the app - Video Player

For this app you will use these coded pages:

1 layout file, main.xml,(already created, just copy paste this tutorial app code into it and save); located at res/layout/.

1 java page,,(already created as rename the page to, add the code from Example Code and save the file) or if you prefer:

You can just delete the page;(already created for us when we made our android template app)
then just create another java page and name it, and add the code from our Example Code Section, to the page, and save the page.(and do camel case your java files when naming them; first letter is capped:

In our file we define our layout views:
setContentView(R.layout.main); and the VideoView layout.
Also, we add the Create method for the VideoView.

1 video file - myvideo.mp4; You can download it from our Example Code section; then add it to your res/raw folder. You will have to create the raw folder. Just create the folder using your Tablet File Manager or in AIDE.
Use your tablets File Manager to copy paste the audio file into the AppProjects/VideoPlayer/app/src/main/res/raw/ folder.

1 strings file, strings.xml (already created) - where we define the app_name for our app. This string, app_name is created automatically for us when we created our android template app. Since we are not adding any additional text to our app view, we don't have to add any strings, therefore, we don't need to do anything on this page.

1 manifest file, AndroidManifest.xml (already created) - where we define the app's name, sdk version, launcher icon, and the app's theme. And, where we define our app's activity page; This must be defined in the Activity element in the manifest file.

This page is created automatically each time you create a new Android Java/xml app. The sdk version, launcher icon, app theme, app name attributes are all added for you when you use an Android Template Java/xml app to create your app project.(we use the template app for our tutorials).

And, you don't need to change code on this page unless:

your adding additional activity pages or changing the name of your to another name;
need to change the SDK version,
need to add Internet permission,
want to change the App's Theme;
or want to add a custom launcher icon

For this app tutorial, Video Player, we changed our page name to; therefore, we need to add this name to the manfest file at the Activity element.
You can just copy paste the code from our Example Code section, to replace the code that's in the androidmanifest.xml file, and save the file.


If you want to add your own video mp4 file to this app you can; just add it to the res/raw folder in your app project. If you are using spacing in your video file name you must use the underscore symbol; like my_video.mp4

EXAMPLE CODE - Code For This Tutorial

JUST USE YOUR MOUSE to copy the code for this tutorial App Name is 'VideoPlayer - located at AppProjects/VideoPlayer in AIDE, open the AIDE app, then open App Projects, THEN select the 'VideoPlayer', app from your files hierachy(left menu); then click on any file from the app, like strings.xml Make sure at top of page, the app name 'VideoPlayer' is there next to AppProjects like so: AppProjects/VideoPlayer, then you know you have the proper App.

Once a file is in the editor, you can edit, save it, then RUN your APP, Install, and Open your app.

Make sure you SAVED EACH PAGE,(or choose automatic saving in AIDE settings) before you RUN your code. SAVE, RUN, INSTALL, OPEN, your App. Once it has been installed on your tablet, you can open it Simply by Clicking on the Android little green App Icon,with the wording 'VideoPlayer' on your tablet. It will be with your other installed apps.

If you make further changes to this App, you need to SAVE, RUN, UPDATE, INSTALL, OPEN the app.

Example Code App - Video Player :
Use Mouse To Copy Paste the Code

click to download this video file
Save it as; myvideo.mp4
Put it at res/raw folder in your project
You have to create the raw folder at res/raw
Click here for the video file

This free script provided by
JavaScript Kit

Share This Page

AIDE for creating Android Apps on your tablet or cell phone(android).
Free and Paid - with Free, create java/xml android template apps, and there is a couple free android coding lessons.
With paid, create java/xml android template apps, and you can create a 'keystore' for your app, so you can publish your apps to the marketplaces like Google Playstore and Amazon.
GoTo Aide

ANDROID STUDIO - for creating Android Apps on your desktop computer.
Free to Install and Use
GoTo Android Studio Learn more - Android Studio

The Java XML files we code(example codes) and the Android Apps we create in our Free Tutorials are compatible with Android Studio and AIDE. Just choose Java XML as your Programming Language.

You May Like:
Make Sushi Rolls Taste World Wines Flavours and Aromas

Java XML
The Coded Pages

Beginners Article
About Our Tutorials
Coding androidmanifest.xml
Coding main.xml
Coding strings.xml
Coding drawables

Java XML
Learning To Code

Create A Simple
Android App

Change App Icon

Add Text and Style

Add Buttons To App

Placing Text in

Change View
Background Color

Change Screen

Add Image to
Activity View

Add Horizontal
Scroll View

Add a Frame Layout

How to Add Themes
To Your App

How To Code
Customized Styles

Code a Toast Message

Coding Resource


Java XML
Adding Features,

Coding Shape
Drawable - Lines

Coding A WebView

Coding A Timed
Screen Splash

Coding A Gradient

Coding Fragments

Coding A
ListView Fragment

Coding a
Tabbed Fragment

Share Intent
for Text

Share Intent
for Images

Media Player
with Audio

Coding A
Video Player

Localize Your App
World Languages

Coding a Simple ListView

ListView with Toast Message

from the Web

Add Clickable Button
To textView

Image Button with

Linear Layout with
weight attribute

OnClick Displays

Screen Density
Coding Practices


for android tablets

Android Studio
For desktop computers


Code Canyon Paid From $1 Free and Paid From $1


App Distribution
Launching Your Android App
How To Be Successful

Android App Libraries
What are they and how
to implement them

How To Implement

View All Articles

Coding Tools

Android Studio
Course - Paid

Java Programming
Course - Free

Git Hub Course

About Our Images

All images on this page are copyrighted material.
You can use the images included with each tutorial for the purpose of creating your android app. These images are not to be distributed or sold.


How To Add Your Google Key
To Manifest.xml
Web Article

How To Sign Your APK Web Article

Google Developer Console
Create Account Submit Your App
Web Article

Amazon App DRM - APK KEY
Amazon Developer Portal
Create Account - Submit Your App

Google's In-App Billing for App monetization.

Monetizing Your App
How Tos

Follow Us On Twitter