Android: How to play RTSP or HLS video streams

19 Sep

Playing rtsp video streams seems to be a complex task in Android, but actually it is insane easy. Here is how.

  • Create a new project using Android Studio
  • Drag a VideoView control to the UI or add below code in the UI xml file:
        android:id="@+id/videoView" />


image   image

Open the activity java file, add below code:

    VideoView  videoView;
    String  videoRtspUrl=rtsp://;
    protected void onCreate(Bundle savedInstanceState) {

        videoView = (VideoView) this.findViewById(;

If you build and run the app, you might encounter an error:

“Can’t play this video”

Add the permission in AndroidManifest before <Application> node:

<uses-permission android:name="android.permission.INTERNET" />

Rebuild, yeah! Success! That is just that simple!

Yes, this approach also works for HLS video streams, e.g.

In short, the built-in VideoPlayer control from Android SDK makes it easy to play RTSP or HLS streams with little efforts!


Posted by on September 19, 2015 in Android, Programming


Tags: , , , , , , , , , ,

3 responses to “Android: How to play RTSP or HLS video streams

  1. Zetla

    February 2, 2017 at 10:50 am

    Thx you very much for this sample! I was looking for a lib to do this and finally a simple videoView do the job !!

    Do you have any sample to do the reverse thing ? I want to send hls or rtmp video stream from my phone camera to my personnal server (working with nginx)


  2. lunot

    March 30, 2017 at 8:51 am

    i tryed this code and its just running hls stream 😦


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: