Search code examples
androidstreaminglivertspwowza

Play RTSP streaming in an Android application


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:

rtsp://tv.hindiworldtv.com:1935/live/getpun

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) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

        //Create a VideoView widget in the layout file
        //use setContentView method to set content of the activity to the layout file which contains videoView
        this.setContentView(R.layout.videoplayer);

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

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

        //Set the path of Video or URI
        videoView.setVideoURI(Uri.parse("rtsp://tv.hindiworldtv.com:1935/live/getpnj"));
        //

        //Set the focus
        videoView.requestFocus();
    }
}

At first, it was not working.

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


Solution

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