Go: Native API play RSTP

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.