目前在做视频应用的时候,比较先进的技术就是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.

效果截图:

 

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

  2. import android.app.Activity;
  3. import android.net.Uri;
  4. import android.os.Bundle;
  5. import android.view.View;
  6. import android.widget.Button;
  7. import android.widget.EditText;
  8. import android.widget.VideoView;

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

  11. Button playButton ;
  12. VideoView videoView ;
  13. EditText rtspUrl ;

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

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

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

  26. }

  27. //play rtsp stream
  28. private void PlayRtspStream(String rtspUrl){
  29. videoView.setVideoURI(Uri.parse(rtspUrl));
  30. videoView.requestFocus();
  31. videoView.start();
  32. }

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

 VideoViewRtsp.rar (23.4 KB, 下载次数: 1223) 

更多相关文章

  1. android流媒体框架介绍
  2. Android本地视频播放器开发--ffmpeg解码视频文件中的音频(1)
  3. Android中播放GIF动画
  4. android之播放多媒体文件一(播放音频)
  5. Android音频系统探究——从SoundPool到AudioHardware
  6. Android(安卓)下的视频播放器faplayer 编译
  7. Android系列教程之六:TextView小组件的使用--附带超链接和跑马灯
  8. Android(安卓)Service的使用方法 音乐播放器实例
  9. 在Android应用中集成YouTube视频播放功能

随机推荐

  1. Android(安卓)原生通知Notification 写法
  2. Android(安卓)64k的string限制
  3. Android(安卓)ListView优化之局部刷新(更
  4. android手机修改系统分变率/修改机型/系
  5. android之碎片fragment的使用
  6. Android(安卓)Studio快捷键大全
  7. Android监测手机网络状态变化的广播
  8. 今晚没看完的几个网页,主要是alarm和一个U
  9. 关于Android中Dialog点击屏幕外失去焦点
  10. --Android引用so文件引发的血案