Load/Play Video From URL Android Kotlin VideoView Programmatically

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

You can load video from URL in android Videoview programmatically.

A small android app which include play, stop, play continuously and play once options.

You can implement this module any other android app as it includes only one class which is simple and easy.

It will be small video control app with kotlin and android studio.

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 Kotlin example tutorial.

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

Step 2: Updating AndroidManifest.xml file

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

Step 3: Updating activity_main.xml file

Add below code in activity_main.xml file

Step 4: Updating MainActivity.kt class : 

Add below code to MainActivity.kt

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

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

Download Source Code for load and play video from url android kotlin

[sociallocker]Download Android Kotlin_VideoView URL Example[/sociallocker]

Hardik Parsania

I am mobile app developer. I am always passionate about solving complex and real world problems.I have developed many apps with great interest and superior logical skills.

You may also like...

Leave a Reply

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