How to Create Android Video Player: 1. Generating Video List from Device

You ever find, few of the app are all most available on every Android Devices. Like Calculator, Calendar, Camera and Off course Video player too. Here I have discussed few, but there might be more.
In this series of tutorial, you will learn how to create video player with few basic steps.
How to Create Android Video Player
So, let’s start with creating project.


Topics Covered

Creating New Project


Warning: Cannot modify header information - headers already sent by (output started at /home/bajayk/public_html/wp-content/plugins/all-in-one-seo-pack/aioseop_class.php:3983) in /home/bajayk/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_wp.class.php on line 220

Create new android project named “Video Player”. Define Main Activity as “VideoListActivity.java” and set layout as “videolist”.


Here is the Layout XML for VideoListActivity under res>layout folder.

Collecting Videos from Device


Warning: Cannot modify header information - headers already sent by (output started at /home/bajayk/public_html/wp-content/plugins/all-in-one-seo-pack/aioseop_class.php:3983) in /home/bajayk/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_wp.class.php on line 220

To show the list of videos, first of all we have to collect all the videos data stored in device.
Below code snippet you can use to collect video data.

Creating Adapter to show the List of Videos


Warning: Cannot modify header information - headers already sent by (output started at /home/bajayk/public_html/wp-content/plugins/all-in-one-seo-pack/aioseop_class.php:3983) in /home/bajayk/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_wp.class.php on line 220

Before create the VideoList Adapter we have to create layout for it. See the image below how the list item layout should look.
How to Create Android Video Player

Create new xml under res>layout named “video_item.xml”.


Now create “VideoAdapter.java” and extend with BaseAdapter class.

Display Videos List on Screen


Warning: Cannot modify header information - headers already sent by (output started at /home/bajayk/public_html/wp-content/plugins/all-in-one-seo-pack/aioseop_class.php:3983) in /home/bajayk/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_wp.class.php on line 220

Now time to display videos list on screen in visual form. To show the list you can use following code snippet.
Define new VideoAdapter by passing generated information of videos which we have collected form device using MediaStore class. And set it to ListView using setAdapter() method.

And here is the output.

How to Create Android Video Player

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

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