Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 360
SJSSoft Avatar asked Jun 30 '12 14:06

SJSSoft


People also ask

How do I play RTSP streams?

Step 1: Download and install VLC Player from http://www.videolan.org/vlc/. Step 2: Open VLC player and select“Open Network Stream”from the Media menu. Step 3: Type the network URL in the dialog box below, and then click Play to play the video with RTSP stream.

Can VLC player play RTSP stream?

Using the VLC player, you can play the video streaming via RTSP protocol. Launch the VLC player and open network stream, type in the URL rtsp://IP Camera's IP Address/channel1. Then you can see the video streaming. E.g. rtsp://192.168.1.100/channel1.

How do I use RTSP in Chrome?

Direct RTSP streaming is still not supported by browsers, if you have to play an RTSP stream in the browser then you need a proxy server that will convert RTSP to HTTP stream.

Does browser support RTSP?

As a rule, browsers do not support RTSP, so the video stream is converted for a browser using an intermediate server.


1 Answers

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));     startActivity(intent); } 

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

like image 85
Jorgesys Avatar answered Sep 18 '22 20:09

Jorgesys