Android Video Streaming VideoView Tutorial

Today Tutorial Video is about how to stream a remote video through Media Controller and display it into Video view in your Android App. Media Controller is main controller for Media Player for example a function like , Play / Pause , Rewind ,Fast Forwarding and showing progress bar . Video can be easily loaded through several source like remote servers , cloud storage , Internal memory cards We will create a button and button click will start streaming remote video as a new activity so lets get started

First of all create  File > New > Android Application Project. Fill in the details and name your project VideoStreamTutorial.

Application Name : VideoStreamTutorial

Project Name : VideoStreamTutorial

Package Name : com.androidbegin.videostreamtutorial

Open your MainActivity.java and paste the following code.

MainActivity.java

In the above code I have created one button after clicking on it ,It will activate one activity
Note : It is very important that your file must Compatible with your Android Mobile

Next, create an XML file for your MainActivity Graphical Layout. Go to res > layout > Right Click on layout > New > Android XML File

Name your new XML file activity_main.xml and paste the following code.

activity_main.xml

In Next Step , create a new activity for streaming remote video . Go to File > New > Class and name it VideoViewActivity.java. Select your package named com.androidbegin.videostreamtutorial and click Finish.

Open your VideoViewActivity.java and paste below code into it

 

In this activity we will show progress bar until video is almost loaded

Next, create an XML file for your VideoViewActivity Graphical Layout. Go to res > layout > Right Click on layout > New > Android XML File

Name your new XML file videoview_main.xml and paste the following code.

videoview_main.xml

Next , change your Application  name and all texts .  Open  strings.xml in your res > values folder and paste the following code.
strings.xml

In your AndroidManifest.xml, we will need to add  activity and a permissions to allow the application to access Web. Open your AndroidManifest.xml and paste the following code.

AndroidManifest.xml

Spread the love

Add a Comment

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