android 播放rtsp

场景:Android VideoView怎么播放RTSP的流

Android VideoView如何播放RTSP的流
目前在做视频应用的时候,比较先进的技术就是RTSP流媒体了,那么如和利用Android的播放控件VideoView来播放RTSP的流呢?

RTSP流媒体链接:
http://218.204.223.237:8081/wap/

这个链接含有所有的RTSP流媒体的链接,现在咱们就用VideoView来播放里面的RTSP的流,咱们以其中的一个链接来测试下好了:

rtsp://218.204.223.237:554/live/1/66251FC11353191F/e7ooqwcfbqjoo80j.sdp.

效果截图:

android 播放rtsp

核心代码如下:
package com.video.rtsp;

import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.VideoView;

public class rtspActivity extends Activity {
/** Called when the activity is first created. */

Button playButton ;
VideoView videoView ;
EditText rtspUrl ;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

rtspUrl = (EditText)this.findViewById(R.id.url);
playButton = (Button)this.findViewById(R.id.start_play);
playButton.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v) {
PlayRtspStream(rtspUrl.getEditableText().toString());
}
});

videoView = (VideoView)this.findViewById(R.id.rtsp_player);

}

//play rtsp stream
private void PlayRtspStream(String rtspUrl){
videoView.setVideoURI(Uri.parse(rtspUrl));
videoView.requestFocus();
videoView.start();
}

}


在点击开始播放后,一般要等个10几秒中才开始播放的,直接的设置需要播放的RTSP的地址:setVideoURI(rtsp的地址)

转自:http://www.shouyanwang.org/thread-96-1-1.html
1 楼 求知者long 2011-10-14  
android 播放rtsp android 播放rtsp android 播放rtsp 试试先!
2 楼 bluskywheat 2012-02-29  
android 播放rtsp Very good!Thanks!
3 楼 bluskywheat 2012-02-29  
请问这个网址提供的rtsp流媒体是H264格式的吗?期待您的答复,谢谢啦
4 楼 lonpo 2012-03-18  
这个地址提供了rtsp流媒体非常好,但是这个流媒体服务器是用什么搭建的呢?如何搭建呢?