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?
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.
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.
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.
As a rule, browsers do not support RTSP, so the video stream is converted for a browser using an intermediate server.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With