Load And Play Video From URL In VideoView Android Studio

Hello, coders. In this load and play video from URL android studio tutorial example, we will learn to play or load video from URL or server.

You can load video from URLin android Videoview programmatically.

First, check the output of this load and play video from URL Android and then we will implement it step by step.

Wait for one minute

Here, we will load or play video from URL. If you wish to load video from Android studio’s raw directory, then check here: Videoview android studio example tutorial.

How to get maximum benefit from load and play video from URL Android

Download Source Code

Try Our App

Download DemoNuts app to learn anytime, anywhere: Click to get Demonuts App

Or search “demonuts” in play store from android mobile device.

Creating load and play video from URL Android

If you are using adblocker, then you will not be able to show our site smoothly. For example, you find step 6 after step 1 or similar to this. So please disable adblocker to fully utilize all resources of DemoNuts

Step 1: Create a new project in the android studio.

Step 2: Updating AndroidManifest.xml file

add internet permission between <manifest>….</manifest> tag.

Note: If you are targeting SDK version above 22 (Above Lollipop)  then you need to ask a user for granting runtime permissions. Check marshmallow runtime permission for more information.

Step 3: Updating activity_main.xml file

Add below code in activity_main.xml file

Step 4: Updating MainActivity.java class : 

Add below code to MainActivity.java

Step 5: Description of MainActivity.java

  • Below code
  • will set mediacontrollers(previous, pause, play, next buttons) to videoview.
  • Below code
  • Here you need to update your server URL to the video.
  •  

  • As you can see we are using boolean isContinuously to detect which button is pressed, Either “ONCE” or “Continuously .
  • We are managing isContinuously and starting a video on both button’s click method as below.

We will remove progressBar when a video is prepared to run. See below code

How to get exact Android example while searching in Google

Click to get Important Google searching tips

So all for this play video url android studio example tutorial. Thank you for your time, keep visiting for more tutorials. ?

One Response
  1. www.linkedin.com

Leave a Reply

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