Android 使用videoview播放Rtsp视频 demo
立即下载
资源介绍:
Android 使用videoview播放Rtsp视频 demo
http://blog.csdn.net/huanzhongying/article/details/53032909
package com.cyun;
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.MediaController;
import android.widget.VideoView;
/**
* @author cyun
* @desc 播放rtsp视频
*/
public class VideoActivity extends Activity implements View.OnClickListener {
private VideoView videoview;
private Button btnplay;
private String urlNet = "http://img1.peiyinxiu.com/2014121211339c64b7fb09742e2c.mp4"; // 动画片
private String urlHaiguan = "rtsp://218.204.223.237:554/live/1/66251FC11353191F/e7ooqwcfbqjoo80j.sdp"; // 海关
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video);
videoview = (VideoView) findViewById(R.id.videoview);
btnplay = (Button) findViewById(R.id.btnplay);
btnplay.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btnplay:
playRtsp();
break;
}
}
private void playRtsp() {
videoview.setMediaController(new MediaController(this));
videoview.setVideoURI(Uri.parse(urlNet)); // urlNet urlHaiguan
videoview.requestFocus();
videoview.start();
}
}