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!

1 Comment

Posted by on September 19, 2015 in Android, Programming


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

One response to “Android: How to play RTSP or HLS video streams

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: