如何在没有任何第三方库的情况下在Android上制作RTSP客户端?

时间:2018-09-12 20:23:41

标签: android rtsp rtsp-client

只看了stackoverflow问题帖子链接 RTSP Client Implementation on Android

找到另一个 Android RTSP Client

试图通过videoview和surfaceview实施。

--http web link video is coming. 
--http using VLC player no video
--rtsp using VLC player no video.

我正在使用Android RTSP客户端中的代码

package com.weeklybuild.rtspviewer;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

import android.net.Uri;
import android.widget.MediaController;
import android.widget.VideoView;

public class MainActivity extends Activity {

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

  String uri = "rtsp://localhost:8554/test";  //giving Url as per VLC 
  VideoView v = (VideoView) findViewById( R.id.videoView );
  v.setVideoURI( Uri.parse(uri) );
  v.setMediaController( new MediaController( this ) );
  v.requestFocus();
  v.start();
 }
}

有人可以告诉我为什么无法使用RTSP观看视频吗?

1 个答案:

答案 0 :(得分:0)

我猜测原因是指定的URI不正确。从链接开始,

rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov

有效,我们可以确保代码可以正常工作。我猜问题是因为问题中提供的URI没有编解码器。

您提供的第二个链接Android RTSP Client还指出编解码器可能存在很多问题。 (链接中的第4节)

我建议添加.stream和检查。如果那不起作用,请尝试使用其他编解码器。