o----http://brianchen85.blogspot.jp/2015/03/android-play-rtsp-vedio.html
Previous introduction to the use of Vitamio third-party components
Although it is powerful, it must be returned to the native
This is to write a simple sample
As there is no test connection, this may be due to Google search
RTSP is the protocol for instant streaming
The possible reasons for the delay of the painting are:
1. Delayed Internet
2. Hand Machine Hardware Specifications
3. Multiple devices connected to the monitoring device
Don't say much, just look at the examples!
Activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/LinearLayout1" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <EditText android:id="@+id/editText" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" > <requestFocus /> </EditText> <Button android:id="@+id/playButton" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Play" /> <VideoView android:id="@+id/rtspVideo" android:layout_width="match_parent" android:layout_height="wrap_content" /></LinearLayout>
Mainactivity.java
Package Com.example.rtsp;import Android.app.activity;import Android.net.uri;import android.os.bundle;import Android.view.view;import Android.view.view.onclicklistener;import Android.widget.button;import Android.widget.edittext;import Android.widget.videoview;public class Mainactivity extends Activity implements onclicklistener{EditText Rtspurl; Button PlayButton; Videoview Videoview; @Override public void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (R.layout.activity_main); Rtspurl = (EditText) This.findviewbyid (R.id.edittext); Videoview = (videoview) This.findviewbyid (R.id.rtspvideo); PlayButton = (Button) This.findviewbyid (R.id.playbutton); Playbutton.setonclicklistener (this); } @Override public void OnClick (view view) {switch (View.getid ()) {R.id.playbutton: Rtspstream (Rtspurl.geteditabletext (). toString ()); Break; }} private void Rtspstream (String rtspurl) {Videoview.setvideouri (Uri.parse (Rtspurl)); Videoview.requestfocus (); Videoview.start (); }}
Remember to add permissions:
<uses-permission android:name="android.permission.INTERNET" />
Complete the Map
Go: Native API play RSTP