tutorial - Play RTSP streaming in an Android application

rtsp player android source code (3)

I am trying to develop an Android based application, which can play video from a live stream. This live stream is produced using Wowza Media Server.

The URL is:


I have tried following code in ecliplse:

package com.kalloh.wpa;

import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.net.Uri;
import android.os.Bundle;
import android.view.Window;
import android.widget.MediaController;
import android.widget.VideoView;

public class a extends Activity {

    VideoView videoView;
    public void onCreate(Bundle savedInstanceState) {

        //Create a VideoView widget in the layout file
        //use setContentView method to set content of the activity to the layout file which contains videoView

        videoView = (VideoView)this.findViewById(R.id.videoView);

        //add controls to a MediaPlayer like play, pause.
        MediaController mc = new MediaController(this);

        //Set the path of Video or URI

        //Set the focus

At first, it was not working.

Now it started working, but it stops after 20 to 30 seconds. How can I fix this problem?

I also had the same problem in ICS 4.x. Also, you can check whether your stream URL is working properly or not.

Also check your code with this sample URL.

I found the solution. Transmission should be within the preferred setting by Android. For more details, see Supported Media Formats.

Using VideoView is a good solution, but we can also use the native player to play RTSP. This is an example:

if (movieurl.startsWith("rtsp://")) {
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(movieurl));

Bear in mind your media must be created with Android Supported Media Formats (codecs).